Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit eb5439ebffc5159c946ccdbce5ff3589d440b466 Author: Joseph Mansy <36427684+yousefmansy1@users.noreply.github.com> Date: Thu Mar 09 12:49:38 2023 +0000 Prefer mp4 extension for video attachments (whatsapp) (#1971) resolves #1967 diff --git a/bridge/whatsappmulti/handlers.go b/bridge/whatsappmulti/handlers.go index 95fe823..fd75be0 100644 --- a/bridge/whatsappmulti/handlers.go +++ b/bridge/whatsappmulti/handlers.go @@ -2117 +21116 @@ 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())