added m.type = file checking to allow plugin to catch heif uploads that are submitted as files rather than images
This commit is contained in:
parent
52cf166960
commit
7a59f69a24
1 changed files with 4 additions and 2 deletions
|
@ -122,7 +122,7 @@ class HateHeifBot(Plugin):
|
||||||
self.rooms = self.config['rooms'] if self.config['rooms'] else None
|
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(
|
async def hate_heif_message(
|
||||||
self,
|
self,
|
||||||
evt: MessageEvent,
|
evt: MessageEvent,
|
||||||
|
@ -137,7 +137,7 @@ class HateHeifBot(Plugin):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Double check if it is an image message
|
# 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
|
return
|
||||||
|
|
||||||
content: MediaMessageEventContent = evt.content
|
content: MediaMessageEventContent = evt.content
|
||||||
|
@ -164,6 +164,8 @@ class HateHeifBot(Plugin):
|
||||||
img = img_out.getvalue()
|
img = img_out.getvalue()
|
||||||
img_tst = Image.open(BytesIO(img))
|
img_tst = Image.open(BytesIO(img))
|
||||||
self.log.debug(f"Created image parameters: {img_tst.format} {img_tst.size} {img_tst.mode}")
|
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:
|
if is_enc:
|
||||||
img_enc = attachments.encrypt_attachment(img)
|
img_enc = attachments.encrypt_attachment(img)
|
||||||
|
|
Loading…
Add table
Reference in a new issue