diff options
author | Joseph Mansy <36427684+yousefmansy1@users.noreply.github.com> | 2023-03-09 12:49:38 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-09 21:49:38 +0100 |
commit | a9ccc18d735ac173c77c61770dc7d097d67b4407 (patch) | |
tree | c169af3fb37cfa7aab0e441609757258a7ee17e5 /bridge/whatsappmulti/handlers.go | |
parent | ac681687f8afe770edbae439e08d49b472517fc6 (diff) | |
download | matterbridge-msglm-a9ccc18d735ac173c77c61770dc7d097d67b4407.tar.gz matterbridge-msglm-a9ccc18d735ac173c77c61770dc7d097d67b4407.tar.bz2 matterbridge-msglm-a9ccc18d735ac173c77c61770dc7d097d67b4407.zip |
Prefer mp4 extension for video attachments (whatsapp) (#1971)
resolves #1967
Diffstat (limited to 'bridge/whatsappmulti/handlers.go')
-rw-r--r-- | bridge/whatsappmulti/handlers.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index 95fe8232..fd75be09 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -211,7 +211,16 @@ func (b *Bwhatsapp) handleVideoMessage(msg *events.Message) { fileExt = append(fileExt, ".mp4") } - filename := fmt.Sprintf("%v%v", msg.Info.ID, fileExt[0]) + // Prefer .mp4 extension, otherwise fallback to first index + fileExtIndex := 0 + for i, n := range fileExt { + if ".mp4" == n { + fileExtIndex = i + break + } + } + + filename := fmt.Sprintf("%v%v", msg.Info.ID, fileExt[fileExtIndex]) b.Log.Debugf("Trying to download %s with size %#v and type %s", filename, imsg.GetFileLength(), imsg.GetMimetype()) |