This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

archiver-bot: handle decryption failures, join pending invites on startup

Add MegolmEvent callback that warns the user when a message can't be
decrypted and requests the missing room key. Also process invited_rooms
from the initial sync so invites that arrived while the bot was offline
are accepted instead of being silently ignored.

+29
+29
5pkgs/archiver-bot/archiver_bot/__init__.py
··· 14 14 InviteMemberEvent, 15 15 LoginResponse, 16 16 MatrixRoom, 17 + MegolmEvent, 17 18 RoomMessageText, 18 19 ) 19 20 ··· 498 499 await send_notice(client, room.room_id, plain, html) 499 500 500 501 502 + async def on_megolm(client: AsyncClient, room: MatrixRoom, event: MegolmEvent): 503 + """Handle messages we couldn't decrypt.""" 504 + log.warning( 505 + f"Failed to decrypt message from {event.sender} in {room.display_name} " 506 + f"(session {event.session_id}): {event.message}" 507 + ) 508 + # Request the keys we're missing 509 + if client.olm: 510 + try: 511 + resp = await client.request_room_key(event) 512 + log.info(f"Requested room key for session {event.session_id}: {resp}") 513 + except Exception as e: 514 + log.warning(f"Failed to request room key: {e}") 515 + await send_notice( 516 + client, 517 + room.room_id, 518 + "🔒 I couldn't decrypt your message. Please try again or re-invite me to this room.", 519 + "🔒 I couldn't decrypt your message. Please try again or re-invite me to this room.", 520 + ) 521 + 522 + 501 523 async def on_invite(client: AsyncClient, room: MatrixRoom, event: InviteMemberEvent): 502 524 """Auto-join rooms when invited.""" 503 525 log.info(f"Invite event in {room.room_id}: state_key={event.state_key}, sender={event.sender}, membership={event.membership}, our_id={client.user_id}") ··· 631 653 await client.close() 632 654 sys.exit(1) 633 655 656 + # Join any rooms we were invited to while offline 657 + for room_id, room in client.invited_rooms.items(): 658 + log.info(f"Joining pending invite for {room_id}...") 659 + result = await client.join(room_id) 660 + log.info(f"Join result for {room_id}: {result}") 661 + 634 662 # E2EE setup 635 663 if client.olm: 636 664 try: ··· 652 680 # Register event callbacks only after initial sync 653 681 client.add_event_callback(lambda room, event: on_message(client, room, event, http), RoomMessageText) 654 682 client.add_event_callback(lambda room, event: on_invite(client, room, event), InviteMemberEvent) 683 + client.add_event_callback(lambda room, event: on_megolm(client, room, event), MegolmEvent) 655 684 656 685 # Start webhook server for Radarr/Sonarr notifications 657 686 app = web.Application()