From 7a59f69a2492d237b32e885dabd338821195cdb3 Mon Sep 17 00:00:00 2001 From: ajkessel Date: Mon, 12 Feb 2024 11:09:19 -0500 Subject: [PATCH] added m.type = file checking to allow plugin to catch heif uploads that are submitted as files rather than images --- hateheif.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hateheif.py b/hateheif.py index 336204f..f2e21c4 100644 --- a/hateheif.py +++ b/hateheif.py @@ -122,7 +122,7 @@ class HateHeifBot(Plugin): self.rooms = self.config['rooms'] if self.config['rooms'] else None - @command.passive("", msgtypes=(MessageType.IMAGE,)) + @command.passive("", msgtypes=(MessageType.IMAGE,MessageType.FILE)) async def hate_heif_message( self, evt: MessageEvent, @@ -137,7 +137,7 @@ class HateHeifBot(Plugin): return # Double check if it is an image message - if evt.content.msgtype != MessageType.IMAGE: + if evt.content.msgtype != MessageType.IMAGE and evt.content.msgtype != MessageType.FILE: return content: MediaMessageEventContent = evt.content @@ -164,6 +164,8 @@ class HateHeifBot(Plugin): img = img_out.getvalue() img_tst = Image.open(BytesIO(img)) self.log.debug(f"Created image parameters: {img_tst.format} {img_tst.size} {img_tst.mode}") + content.info.width=img_tst.size[0] + content.info.height=img_tst.size[1] if is_enc: img_enc = attachments.encrypt_attachment(img)