nix-packages/matrix/mautrix-discord/sticker.patch

38 lines
1.4 KiB
Diff
Raw Normal View History

2022-08-22 19:33:48 +00:00
diff --git a/portal.go b/portal.go
2022-11-19 09:38:00 +00:00
index 3907859..25e0dc2 100644
2022-08-22 19:33:48 +00:00
--- a/portal.go
+++ b/portal.go
2022-11-19 09:38:00 +00:00
@@ -920,7 +920,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType
2022-08-22 19:33:48 +00:00
func (portal *Portal) handleMatrixMessages(msg portalMatrixMessage) {
switch msg.evt.Type {
- case event.EventMessage:
+ case event.EventMessage, event.EventSticker:
portal.handleMatrixMessage(msg.user, msg.evt)
case event.EventRedaction:
portal.handleMatrixRedaction(msg.user, msg.evt)
2022-11-19 09:38:00 +00:00
@@ -1184,13 +1184,22 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
2022-08-22 19:33:48 +00:00
}
}
sendReq.Content = portal.parseMatrixHTML(sender, content)
- case event.MsgAudio, event.MsgFile, event.MsgImage, event.MsgVideo:
+ case event.MsgAudio, event.MsgFile, event.MsgImage, event.MsgVideo, "": // MsgType is empty when the message is a sticker
data, err := portal.downloadMatrixAttachment(content)
if err != nil {
go portal.sendMessageMetrics(evt, err, "Error downloading media in")
2022-09-25 19:06:33 +00:00
return
}
2022-11-19 09:38:00 +00:00
+ // extract file suffix from mime type
+ mimeParts := strings.Split(content.Info.MimeType, "/")
2022-09-25 19:06:33 +00:00
+
2022-11-19 09:38:00 +00:00
+ if content.MsgType == "" {
+ // the Body doesnt contain the file name for stickers
+ content.Body = "sticker."
+ content.Body += mimeParts[1]
+ }
2022-09-25 19:06:33 +00:00
+
sendReq.Files = []*discordgo.File{{
Name: content.Body,
ContentType: content.Info.MimeType,