Handle call start messages

Closes #53
This commit is contained in:
Tulir Asokan
2023-02-13 00:14:02 +02:00
parent 011c60610a
commit 6ccf87bc0a

View File

@@ -964,6 +964,12 @@ func getEmbedType(embed *discordgo.MessageEmbed) BridgeEmbedType {
} }
func (portal *Portal) convertDiscordTextMessage(intent *appservice.IntentAPI, msg *discordgo.Message, relation *event.RelatesTo, isEdit bool) *ConvertedMessage { func (portal *Portal) convertDiscordTextMessage(intent *appservice.IntentAPI, msg *discordgo.Message, relation *event.RelatesTo, isEdit bool) *ConvertedMessage {
if msg.Type == discordgo.MessageTypeCall {
return &ConvertedMessage{Content: &event.MessageEventContent{
MsgType: event.MsgEmote,
Body: "started a call",
}}
}
var htmlParts []string var htmlParts []string
if msg.Interaction != nil { if msg.Interaction != nil {
puppet := portal.bridge.GetPuppetByID(msg.Interaction.User.ID) puppet := portal.bridge.GetPuppetByID(msg.Interaction.User.ID)
@@ -1188,6 +1194,9 @@ func (portal *Portal) handleDiscordMessageUpdate(user *User, msg *discordgo.Mess
if !ok { if !ok {
portal.log.Debugfln("Dropping edit with no author of non-recent message %s", msg.ID) portal.log.Debugfln("Dropping edit with no author of non-recent message %s", msg.ID)
return return
} else if creationMessage.Type == discordgo.MessageTypeCall {
portal.log.Debugfln("Dropping edit of call message %s", msg.ID)
return
} }
portal.log.Debugfln("Found original message %s in cache for edit without author", msg.ID) portal.log.Debugfln("Found original message %s in cache for edit without author", msg.ID)
if len(msg.Embeds) > 0 { if len(msg.Embeds) > 0 {
@@ -1254,8 +1263,10 @@ func (portal *Portal) handleDiscordMessageUpdate(user *User, msg *discordgo.Mess
return return
} }
converted.Content.SetEdit(existing[0].MXID) converted.Content.SetEdit(existing[0].MXID)
converted.Extra = map[string]any{ if converted.Extra != nil {
"m.new_content": converted.Extra, converted.Extra = map[string]any{
"m.new_content": converted.Extra,
}
} }
var editTS int64 var editTS int64