mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-14 09:23:51 +01:00
Clamp sticker rendering suggestion 190px
This commit is contained in:
parent
f8d6f712bd
commit
1b90f98961
1 changed files with 12 additions and 0 deletions
12
portal.go
12
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:
|
||||
|
|
Loading…
Reference in a new issue