diff --git a/matrix_alertbot/callback.py b/matrix_alertbot/callback.py index 024e538..967002e 100644 --- a/matrix_alertbot/callback.py +++ b/matrix_alertbot/callback.py @@ -204,6 +204,33 @@ class Callbacks: ) await command.process() + async def redaction(self, room: MatrixRoom, event: RedactionEvent) -> None: + # Ignore events from unauthorized room + if room.room_id != self.config.room_id: + return + + # Ignore redactions from ourselves + if event.sender == self.config.user_id: + return + + reacted_to_id = self.cache[event.redacts] + reacted_to_event = await self.client.room_get_event(room.room_id, reacted_to_id) + if isinstance(reacted_to_event, RoomGetEventError): + logger.warning(f"Error getting event that was reacted to ({reacted_to_id})") + return + + command = Command( + self.client, + self.cache, + self.alertmanager, + self.config, + "unack", + room, + event.sender, + reacted_to_id, + ) + await command.process() + async def decryption_failure(self, room: MatrixRoom, event: MegolmEvent) -> None: """Callback for when an event fails to decrypt. Inform the user. @@ -226,21 +253,6 @@ class Callbacks: f"commands a second time)." ) - async def redaction(self, room: MatrixRoom, event: RedactionEvent) -> None: - # Ignore events from unauthorized room - if room.room_id != self.config.room_id: - return - - # Ignore redactions from ourselves - if event.sender == self.config.user_id: - return - - reacted_to_event_id = self.cache[event.redacts] - reacted_to_event = await self.client.room_get_event( - room.room_id, reacted_to_event_id - ) - print(reacted_to_event.event.source) - async def unknown(self, room: MatrixRoom, event: UnknownEvent) -> None: """Callback for when an event with a type that is unknown to matrix-nio is received. Currently this is used for reaction events, which are not yet part of a released