Explorar o código

media download: raise AttachmentTooLargeError preemptively

This prevents us from trying to bridge media that will be too big.
Sumner Evans %!s(int64=3) %!d(string=hai) anos
pai
achega
4879bf171a
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      mautrix_signal/portal.py

+ 2 - 0
mautrix_signal/portal.py

@@ -287,6 +287,8 @@ class Portal(DBPortal, BasePortal):
         return str(path)
 
     async def _download_matrix_media(self, message: MediaMessageEventContent) -> str:
+        if message.info.size > 100 * 10**6:
+            raise AttachmentTooLargeError({"filename": message.body})
         if message.file:
             data = await self.main_intent.download_media(message.file.url)
             data = decrypt_attachment(