فهرست منبع

checkpoints: send in more redaction cases

Sumner Evans 4 سال پیش
والد
کامیت
34eeca0821
2فایلهای تغییر یافته به همراه18 افزوده شده و 1 حذف شده
  1. 8 0
      mautrix_instagram/matrix.py
  2. 10 1
      mautrix_instagram/portal.py

+ 8 - 0
mautrix_instagram/matrix.py

@@ -19,6 +19,7 @@ from mautrix.bridge import BaseMatrixHandler
 from mautrix.types import (Event, ReactionEvent, RoomID, EventID, UserID, ReactionEventContent,
 from mautrix.types import (Event, ReactionEvent, RoomID, EventID, UserID, ReactionEventContent,
                            RelationType, EventType, ReceiptEvent, TypingEvent, PresenceEvent,
                            RelationType, EventType, ReceiptEvent, TypingEvent, PresenceEvent,
                            RedactionEvent, SingleReceiptEventContent)
                            RedactionEvent, SingleReceiptEventContent)
+from mautrix.util.message_send_checkpoint import MessageSendCheckpointStatus
 
 
 from .db import Message as DBMessage
 from .db import Message as DBMessage
 from . import portal as po, user as u
 from . import portal as po, user as u
@@ -64,6 +65,13 @@ class MatrixHandler(BaseMatrixHandler):
 
 
         portal = await po.Portal.get_by_mxid(room_id)
         portal = await po.Portal.get_by_mxid(room_id)
         if not portal:
         if not portal:
+            user.send_remote_checkpoint(
+                MessageSendCheckpointStatus.PERM_FAILURE,
+                event_id,
+                self.mxid,
+                EventType.ROOM_REDACTION,
+                error=Exception(f"Redaction event {event_id} is in non-portal room {room_id}"),
+            )
             return
             return
 
 
         await portal.handle_matrix_redaction(user, event_id, redaction_event_id)
         await portal.handle_matrix_redaction(user, event_id, redaction_event_id)

+ 10 - 1
mautrix_instagram/portal.py

@@ -144,7 +144,7 @@ class Portal(DBPortal, BasePortal):
             self.mxid,
             self.mxid,
             event_type,
             event_type,
             message_type=message_type,
             message_type=message_type,
-            error=err
+            error=err,
         )
         )
 
 
         if self.config["bridge.delivery_error_reports"]:
         if self.config["bridge.delivery_error_reports"]:
@@ -388,6 +388,15 @@ class Portal(DBPortal, BasePortal):
                 )
                 )
                 await self._send_delivery_receipt(redaction_event_id)
                 await self._send_delivery_receipt(redaction_event_id)
                 self.log.trace(f"Removed {reaction} after Matrix redaction")
                 self.log.trace(f"Removed {reaction} after Matrix redaction")
+            return
+
+        sender.send_remote_checkpoint(
+            MessageSendCheckpointStatus.PERM_FAILURE,
+            event_id,
+            self.mxid,
+            EventType.ROOM_REDACTION,
+            error=Exception(f"No message or reaction found for redaction of {event_id}"),
+        )
 
 
     async def handle_matrix_typing(self, users: Set[UserID]) -> None:
     async def handle_matrix_typing(self, users: Set[UserID]) -> None:
         if users == self._typing:
         if users == self._typing: