Explorar el Código

portal._expire_event: raise exception if portal not found

Sumner Evans hace 3 años
padre
commit
e51b580461
Se han modificado 1 ficheros con 5 adiciones y 4 borrados
  1. 5 4
      mautrix_signal/portal.py

+ 5 - 4
mautrix_signal/portal.py

@@ -550,6 +550,11 @@ class Portal(DBPortal, BasePortal):
         mechanism to stop the countdown, even after bridge restart.
         """
         room_id = disappearing_message.room_id
+
+        portal = await cls.get_by_mxid(room_id)
+        if not portal:
+            raise AttributeError(f"No portal found for {room_id}")
+
         event_id = disappearing_message.mxid
         wait = disappearing_message.expiration_seconds
         # If there is an expiration_ts, then there was probably a bridge restart, so we have to
@@ -566,10 +571,6 @@ class Portal(DBPortal, BasePortal):
         if wait < 0:
             wait = 0
 
-        portal = await cls.get_by_mxid(room_id)
-        if not portal:
-            portal.log.warning(f"No portal for {room_id}")
-
         portal.log.debug(f"Redacting {event_id} in {wait} seconds")
         await asyncio.sleep(wait)