From c926569033bce8f52d49d54bf23c0d77439c1936 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Tue, 10 Feb 2026 09:05:20 +0100 Subject: [PATCH] fix(matrix): guard store load without device id and allow invites by default --- nanobot/channels/matrix.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/nanobot/channels/matrix.py b/nanobot/channels/matrix.py index f3b8468..340ec2a 100644 --- a/nanobot/channels/matrix.py +++ b/nanobot/channels/matrix.py @@ -43,7 +43,8 @@ class MatrixChannel(BaseChannel): self.client.add_event_callback(self._on_message, RoomMessageText) self.client.add_event_callback(self._on_room_invite, InviteEvent) - self.client.load_store() + if self.config.device_id: + self.client.load_store() self._sync_task = asyncio.create_task(self._sync_loop()) @@ -74,9 +75,12 @@ class MatrixChannel(BaseChannel): except Exception: await asyncio.sleep(2) - async def _on_room_invite(self, room: MatrixRoom, event: RoomMessageText) -> None: - if event.sender in self.config.allow_from: - await self.client.join(room.room_id) + async def _on_room_invite(self, room: MatrixRoom, event: InviteEvent) -> None: + allow_from = self.config.allow_from or [] + if allow_from and event.sender not in allow_from: + return + + await self.client.join(room.room_id) async def _on_message(self, room: MatrixRoom, event: RoomMessageText) -> None: # Ignore self messages