Skip to content

Commit 2b61a90

Browse files
author
Nicolás Gudiño
committed
Default to .ogg extension if mime.ExtensionByType fails for some reason. Fixes not receiving audios for some users
1 parent 7988672 commit 2b61a90

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

wmiau.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,13 @@ func (mycli *MyClient) myEventHandler(rawEvt interface{}) {
408408
return
409409
}
410410
exts, _ := mime.ExtensionsByType(audio.GetMimetype())
411-
path = filepath.Join(userDirectory, evt.Info.ID+exts[0])
411+
var ext string
412+
if len(exts) > 0 {
413+
ext = exts[0]
414+
} else {
415+
ext = ".ogg"
416+
}
417+
path = filepath.Join(userDirectory, evt.Info.ID+exts)
412418
err = os.WriteFile(path, data, 0600)
413419
if err != nil {
414420
log.Error().Err(err).Msg("Failed to save audio")

0 commit comments

Comments
 (0)