Fix sticker patch

This commit is contained in:
Charlotte 🦝 Delenk 2022-11-19 10:38:00 +01:00
parent ec55e8f9ac
commit 5420eb6131
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122

View file

@ -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 doesnt contain the file name for stickers
+ content.Body = "sticker."
+ content.Body += mimeParts[1]
+ }
+
sendReq.Files = []*discordgo.File{{
Name: content.Body,