add support for reaction removal

This commit is contained in:
HgO 2022-07-10 14:59:21 +02:00
parent 69b5aa20b1
commit 9ee0064153

View file

@ -204,6 +204,33 @@ class Callbacks:
) )
await command.process() 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: async def decryption_failure(self, room: MatrixRoom, event: MegolmEvent) -> None:
"""Callback for when an event fails to decrypt. Inform the user. """Callback for when an event fails to decrypt. Inform the user.
@ -226,21 +253,6 @@ class Callbacks:
f"commands a second time)." 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: 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. """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 Currently this is used for reaction events, which are not yet part of a released