From 5420eb613161fb2fb74c733094580de0d0793f9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charlotte=20=F0=9F=A6=9D=20Delenk?= Date: Sat, 19 Nov 2022 10:38:00 +0100 Subject: [PATCH] Fix sticker patch --- matrix/mautrix-discord/sticker.patch | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/matrix/mautrix-discord/sticker.patch b/matrix/mautrix-discord/sticker.patch index 50e9702..571df31 100644 --- a/matrix/mautrix-discord/sticker.patch +++ b/matrix/mautrix-discord/sticker.patch @@ -1,8 +1,8 @@ diff --git a/portal.go b/portal.go -index d93ad17..198a12c 100644 +index 3907859..25e0dc2 100644 --- a/portal.go +++ b/portal.go -@@ -874,7 +874,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType +@@ -920,7 +920,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) { switch msg.evt.Type { @@ -11,7 +11,7 @@ index d93ad17..198a12c 100644 portal.handleMatrixMessage(msg.user, msg.evt) case event.EventRedaction: portal.handleMatrixRedaction(msg.user, msg.evt) -@@ -1138,13 +1138,20 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) { +@@ -1184,13 +1184,22 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) { } } sendReq.Content = portal.parseMatrixHTML(sender, content) @@ -23,12 +23,14 @@ index d93ad17..198a12c 100644 return } -+ // extract file suffix from mime type -+ mimeParts := strings.Split(content.Info.MimeType, "/") ++ // extract file suffix from mime type ++ mimeParts := strings.Split(content.Info.MimeType, "/") + -+ if content.MsgType == "" && !strings.HasSuffix(content.Body, "." + mimeParts[1]) { -+ content.Body += mimeParts[1] -+ } ++ if content.MsgType == "" { ++ // the Body doesn’t contain the file name for stickers ++ content.Body = "sticker." ++ content.Body += mimeParts[1] ++ } + sendReq.Files = []*discordgo.File{{ Name: content.Body,