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

37 lines
1.4 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git a/portal.go b/portal.go
index 3907859..25e0dc2 100644
--- a/portal.go
+++ b/portal.go
@@ -920,7 +920,7 @@ func (portal *Portal) sendMatrixMessage(intent *appservice.IntentAPI, eventType
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)
@@ -1184,13 +1184,22 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
}
}
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")
return
}
+ // extract file suffix from mime type
+ mimeParts := strings.Split(content.Info.MimeType, "/")
+
+ 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,
ContentType: content.Info.MimeType,