parent
9d6b9a901d
commit
9cc8b04c8e
1 changed files with 13 additions and 10 deletions
17
portal.go
17
portal.go
|
@ -199,15 +199,15 @@ func (portal *Portal) handleMessage(msg PortalMessage) {
|
||||||
case whatsapp.TextMessage:
|
case whatsapp.TextMessage:
|
||||||
portal.HandleTextMessage(msg.source, data)
|
portal.HandleTextMessage(msg.source, data)
|
||||||
case whatsapp.ImageMessage:
|
case whatsapp.ImageMessage:
|
||||||
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, data.Caption, 0, false)
|
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, data.Caption, "", 0, false)
|
||||||
case whatsapp.StickerMessage:
|
case whatsapp.StickerMessage:
|
||||||
portal.HandleMediaMessage(msg.source, data.Download, nil, data.Info, data.ContextInfo, data.Type, "", 0, true)
|
portal.HandleMediaMessage(msg.source, data.Download, nil, data.Info, data.ContextInfo, data.Type, "", "", 0, true)
|
||||||
case whatsapp.VideoMessage:
|
case whatsapp.VideoMessage:
|
||||||
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, data.Caption, data.Length, false)
|
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, data.Caption, "", data.Length, false)
|
||||||
case whatsapp.AudioMessage:
|
case whatsapp.AudioMessage:
|
||||||
portal.HandleMediaMessage(msg.source, data.Download, nil, data.Info, data.ContextInfo, data.Type, "", data.Length, false)
|
portal.HandleMediaMessage(msg.source, data.Download, nil, data.Info, data.ContextInfo, data.Type, "", "", data.Length, false)
|
||||||
case whatsapp.DocumentMessage:
|
case whatsapp.DocumentMessage:
|
||||||
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, data.Title, 0, false)
|
portal.HandleMediaMessage(msg.source, data.Download, data.Thumbnail, data.Info, data.ContextInfo, data.Type, "", data.Title, 0, false)
|
||||||
case whatsapp.ContactMessage:
|
case whatsapp.ContactMessage:
|
||||||
portal.HandleContactMessage(msg.source, data)
|
portal.HandleContactMessage(msg.source, data)
|
||||||
case whatsapp.LocationMessage:
|
case whatsapp.LocationMessage:
|
||||||
|
@ -1253,7 +1253,7 @@ func (portal *Portal) encryptFile(data []byte, mimeType string) ([]byte, string,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (portal *Portal) HandleMediaMessage(source *User, download func() ([]byte, error), thumbnail []byte, info whatsapp.MessageInfo, context whatsapp.ContextInfo, mimeType, caption string, length uint32, sendAsSticker bool) {
|
func (portal *Portal) HandleMediaMessage(source *User, download func() ([]byte, error), thumbnail []byte, info whatsapp.MessageInfo, context whatsapp.ContextInfo, mimeType, caption, fileName string, length uint32, sendAsSticker bool) {
|
||||||
intent := portal.startHandling(source, info)
|
intent := portal.startHandling(source, info)
|
||||||
if intent == nil {
|
if intent == nil {
|
||||||
return
|
return
|
||||||
|
@ -1309,11 +1309,14 @@ func (portal *Portal) HandleMediaMessage(source *User, download func() ([]byte,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := info.Id
|
if fileName == "" {
|
||||||
|
fileName = info.Id
|
||||||
|
|
||||||
exts, _ := mime.ExtensionsByType(mimeType)
|
exts, _ := mime.ExtensionsByType(mimeType)
|
||||||
if exts != nil && len(exts) > 0 {
|
if exts != nil && len(exts) > 0 {
|
||||||
fileName += exts[0]
|
fileName += exts[0]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
content := &event.MessageEventContent{
|
content := &event.MessageEventContent{
|
||||||
Body: fileName,
|
Body: fileName,
|
||||||
|
|
Loading…
Reference in a new issue