mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-13 17:13:11 +01:00
Get Matrix msgtype from WhatsApp type instead of mimetype
This commit is contained in:
parent
91b4699e2d
commit
f8d6f712bd
1 changed files with 13 additions and 15 deletions
28
portal.go
28
portal.go
|
@ -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
|
||||
if isSticker {
|
||||
switch msg.(type) {
|
||||
case *waProto.ImageMessage:
|
||||
content.MsgType = event.MsgImage
|
||||
case *waProto.StickerMessage:
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue