fix: use ReactionEvent instead of UnknownEvent for approval reactions
matrix-nio parses m.reaction as ReactionEvent with .reacts_to and .key fields. UnknownEvent handler never fired for reactions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
bot.py
17
bot.py
@@ -25,6 +25,7 @@ from nio import (
|
||||
LoginResponse,
|
||||
InviteMemberEvent,
|
||||
MegolmEvent,
|
||||
ReactionEvent,
|
||||
RoomEncryptedFile,
|
||||
RoomEncryptedImage,
|
||||
RoomMessageFile,
|
||||
@@ -1268,7 +1269,7 @@ class Bot:
|
||||
self.client.add_event_callback(self.on_file_message, RoomMessageFile)
|
||||
self.client.add_event_callback(self.on_encrypted_file_message, RoomEncryptedFile)
|
||||
self.client.add_event_callback(self.on_room_unknown, RoomMessageUnknown)
|
||||
self.client.add_event_callback(self.on_reaction, UnknownEvent)
|
||||
self.client.add_event_callback(self.on_reaction, ReactionEvent)
|
||||
self.client.add_response_callback(self.on_sync, SyncResponse)
|
||||
self.client.add_to_device_callback(self.on_key_verification, KeyVerificationStart)
|
||||
self.client.add_to_device_callback(self.on_key_verification, KeyVerificationKey)
|
||||
@@ -1464,23 +1465,15 @@ class Bot:
|
||||
self.client.verify_device(device)
|
||||
logger.info("Auto-trusted device %s of %s", device.device_id, user_id)
|
||||
|
||||
async def on_reaction(self, room, event: UnknownEvent):
|
||||
async def on_reaction(self, room, event: ReactionEvent):
|
||||
"""Handle reaction events for pipeline approval flow."""
|
||||
if event.sender == BOT_USER:
|
||||
return
|
||||
if not self._sync_token_received:
|
||||
return
|
||||
source = event.source or {}
|
||||
if source.get("type") != "m.reaction":
|
||||
return
|
||||
|
||||
content = source.get("content", {})
|
||||
relates_to = content.get("m.relates_to", {})
|
||||
if relates_to.get("rel_type") != "m.annotation":
|
||||
return
|
||||
|
||||
event_id = relates_to.get("event_id", "")
|
||||
reaction_key = relates_to.get("key", "")
|
||||
event_id = event.reacts_to
|
||||
reaction_key = event.key
|
||||
|
||||
# Check if this reaction is for a pipeline approval
|
||||
if not self.cron_scheduler:
|
||||
|
||||
Reference in New Issue
Block a user