Răsfoiți Sursa

media download: raise AttachmentTooLargeError preemptively

This prevents us from trying to bridge media that will be too big.
Sumner Evans 3 ani în urmă
părinte
comite
4879bf171a
1 a modificat fișierele cu 2 adăugiri și 0 ștergeri
  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(