Merge pull request #24 from DarkKirb/mautrix-discord-changes

mautrix discord changes
This commit is contained in:
Charlotte 🦝 Delenk 2022-11-19 10:46:04 +01:00 committed by GitHub
commit e2effcee75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 8 deletions

View file

@ -0,0 +1,26 @@
diff --git a/portal.go b/portal.go
index 25e0dc2..7a14a3d 100644
--- a/portal.go
+++ b/portal.go
@@ -351,7 +351,7 @@ func (portal *Portal) CreateMatrixRoom(user *User, channel *discordgo.Channel) e
creationContent := make(map[string]interface{})
if portal.Type == discordgo.ChannelTypeGuildCategory {
- creationContent["type"] = event.RoomTypeSpace
+ return nil
}
if !portal.bridge.Config.Bridge.FederateRooms {
creationContent["m.federate"] = false
@@ -1777,11 +1777,7 @@ func (portal *Portal) UpdateParent(parentID string) bool {
}
portal.log.Debugfln("Updating parent ID %q -> %q", portal.ParentID, parentID)
portal.ParentID = parentID
- if portal.ParentID != "" {
- portal.Parent = portal.bridge.GetPortalByID(database.NewPortalKey(parentID, ""), discordgo.ChannelTypeGuildCategory)
- } else {
- portal.Parent = nil
- }
+ portal.Parent = nil
return true
}

View file

@ -1,8 +1,8 @@
diff --git a/portal.go b/portal.go
index d93ad17..198a12c 100644
index 3907859..25e0dc2 100644
--- a/portal.go
+++ b/portal.go
@@ -874,7 +874,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType
@@ -920,7 +920,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType
func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) {
switch msg.evt.Type {
@ -11,7 +11,7 @@ index d93ad17..198a12c 100644
portal.handleMatrixMessage(msg.user, msg.evt)
case event.EventRedaction:
portal.handleMatrixRedaction(msg.user, msg.evt)
@@ -1138,13 +1138,20 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
@@ -1184,13 +1184,22 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
}
}
sendReq.Content = portal.parseMatrixHTML(sender, content)
@ -23,12 +23,14 @@ index d93ad17..198a12c 100644
return
}
+ // extract file suffix from mime type
+ mimeParts := strings.Split(content.Info.MimeType, "/")
+ // extract file suffix from mime type
+ mimeParts := strings.Split(content.Info.MimeType, "/")
+
+ if content.MsgType == "" && !strings.HasSuffix(content.Body, "." + mimeParts[1]) {
+ content.Body += mimeParts[1]
+ }
+ if content.MsgType == "" {
+ // the Body doesnt contain the file name for stickers
+ content.Body = "sticker."
+ content.Body += mimeParts[1]
+ }
+
sendReq.Files = []*discordgo.File{{
Name: content.Body,