Skip to content

Commit fc80df5

Browse files
author
Swirly
committed
fix the way audio handling works
1 parent 6214301 commit fc80df5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bridge/matrix/matrix.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"path"
1313
"regexp"
1414
"strings"
15+
"slices"
1516
"sync"
1617
"time"
1718

@@ -31,6 +32,8 @@ import (
3132
"maunium.net/go/mautrix/id"
3233
)
3334

35+
var Audio_MimeTypes = []string{"aac", "flac", "matroska", "mp4", "mpeg", "ogg", "opus", "vorbis", "wav"}
36+
3437
var (
3538
htmlTag = regexp.MustCompile("</.*?>")
3639
htmlReplacementTag = regexp.MustCompile("<[^>]*>")
@@ -932,7 +935,7 @@ func (b *Bmatrix) handleUploadFile(msg *config.Message, roomID id.RoomID, fi *co
932935
if err != nil {
933936
b.Log.Errorf("sendImage failed: %#v", err)
934937
}
935-
case strings.Contains(mtype, "audio") && regexp.MustCompile(`(aac|flac|matroska|mp4|mpeg|ogg|opus|vorbis|wav)$`).MatchString(mtype): // god this is such a hack
938+
case strings.HasPrefix(mtype, "audio/") && func() bool { s, _ := strings.CutPrefix(mtype, "audio/"); return slices.Contains(Audio_MimeTypes, s) }():
936939
b.Log.Debugf("sendAudio %s", res.ContentURI)
937940
err = b.retry(func() error {
938941
content := event.MessageEventContent{

0 commit comments

Comments
 (0)