Fix bridging audio/video duration from/to WhatsApp

This commit is contained in:
Tulir Asokan 2021-06-22 20:03:22 +03:00
parent bd207df82d
commit 252d645fea

View file

@ -273,12 +273,12 @@ func (portal *Portal) handleMessage(msg PortalMessage, isBackfill bool) {
base: base{data.Download, data.Info, data.ContextInfo, data.Type}, base: base{data.Download, data.Info, data.ContextInfo, data.Type},
thumbnail: data.Thumbnail, thumbnail: data.Thumbnail,
caption: data.Caption, caption: data.Caption,
length: data.Length, length: data.Length * 1000,
}) })
case whatsapp.AudioMessage: case whatsapp.AudioMessage:
portal.HandleMediaMessage(msg.source, mediaMessage{ portal.HandleMediaMessage(msg.source, mediaMessage{
base: base{data.Download, data.Info, data.ContextInfo, data.Type}, base: base{data.Download, data.Info, data.ContextInfo, data.Type},
length: data.Length, length: data.Length * 1000,
}) })
case whatsapp.DocumentMessage: case whatsapp.DocumentMessage:
fileName := data.FileName fileName := data.FileName
@ -2110,7 +2110,7 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) (*waP
if media == nil { if media == nil {
return nil, sender return nil, sender
} }
duration := uint32(content.GetInfo().Duration) duration := uint32(content.GetInfo().Duration / 1000)
ctxInfo.MentionedJid = media.MentionedJIDs ctxInfo.MentionedJid = media.MentionedJIDs
info.Message.VideoMessage = &waProto.VideoMessage{ info.Message.VideoMessage = &waProto.VideoMessage{
ContextInfo: ctxInfo, ContextInfo: ctxInfo,
@ -2130,7 +2130,7 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) (*waP
if media == nil { if media == nil {
return nil, sender return nil, sender
} }
duration := uint32(content.GetInfo().Duration) duration := uint32(content.GetInfo().Duration / 1000)
info.Message.AudioMessage = &waProto.AudioMessage{ info.Message.AudioMessage = &waProto.AudioMessage{
ContextInfo: ctxInfo, ContextInfo: ctxInfo,
Url: &media.URL, Url: &media.URL,