From 1b90f989616f7dbd5fd33b401a0214492e4af1bb Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Tue, 5 Jul 2022 12:52:32 +0300 Subject: [PATCH] Clamp sticker rendering suggestion 190px --- portal.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/portal.go b/portal.go index f451476..330598d 100644 --- a/portal.go +++ b/portal.go @@ -2276,6 +2276,8 @@ type MediaMessageWithDuration interface { GetSeconds() uint32 } +const WhatsAppStickerSize = 190 + func (portal *Portal) convertMediaMessageContent(intent *appservice.IntentAPI, msg MediaMessage) *ConvertedMessage { content := &event.MessageEventContent{ Info: &event.FileInfo{ @@ -2355,6 +2357,16 @@ func (portal *Portal) convertMediaMessageContent(intent *appservice.IntentAPI, m content.MsgType = event.MsgImage case *waProto.StickerMessage: eventType = event.EventSticker + if content.Info.Width > content.Info.Height { + content.Info.Height /= content.Info.Width / WhatsAppStickerSize + content.Info.Width = WhatsAppStickerSize + } else if content.Info.Width < content.Info.Height { + content.Info.Width /= content.Info.Height / WhatsAppStickerSize + content.Info.Height = WhatsAppStickerSize + } else { + content.Info.Width = WhatsAppStickerSize + content.Info.Height = WhatsAppStickerSize + } case *waProto.VideoMessage: content.MsgType = event.MsgVideo case *waProto.AudioMessage: