Clamp sticker rendering suggestion 190px

This commit is contained in:
Tulir Asokan 2022-07-05 12:52:32 +03:00
parent f8d6f712bd
commit 1b90f98961

View file

@ -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: