소스 검색

media download: raise AttachmentTooLargeError preemptively

This prevents us from trying to bridge media that will be too big.
Sumner Evans 3 년 전
부모
커밋
4879bf171a
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  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(