Get Matrix msgtype from WhatsApp type instead of mimetype

This commit is contained in:
Tulir Asokan 2022-07-05 12:46:34 +03:00
parent 91b4699e2d
commit f8d6f712bd

View file

@ -2349,23 +2349,21 @@ func (portal *Portal) convertMediaMessageContent(intent *appservice.IntentAPI, m
} }
} }
_, isSticker := msg.(*waProto.StickerMessage)
switch strings.ToLower(strings.Split(msg.GetMimetype(), "/")[0]) {
case "image":
if !isSticker {
content.MsgType = event.MsgImage
}
case "video":
content.MsgType = event.MsgVideo
case "audio":
content.MsgType = event.MsgAudio
default:
content.MsgType = event.MsgFile
}
eventType := event.EventMessage eventType := event.EventMessage
if isSticker { switch msg.(type) {
case *waProto.ImageMessage:
content.MsgType = event.MsgImage
case *waProto.StickerMessage:
eventType = event.EventSticker eventType = event.EventSticker
case *waProto.VideoMessage:
content.MsgType = event.MsgVideo
case *waProto.AudioMessage:
content.MsgType = event.MsgAudio
case *waProto.DocumentMessage:
content.MsgType = event.MsgFile
default:
portal.log.Warnfln("Unexpected media type %T in convertMediaMessageContent", msg)
content.MsgType = event.MsgFile
} }
audioMessage, ok := msg.(*waProto.AudioMessage) audioMessage, ok := msg.(*waProto.AudioMessage)