diff --git a/TODO.md b/TODO.md index 6b1355c3..586eec96 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ # TODO -- get devices for members with no shared E2E room? +- highlight when logging in to new account +- warn about no E2E room shared if no devices - keyboard controls - remove useless Base imports in Base components - HTile enter trigger leftClicked() @@ -186,10 +187,8 @@ - Live-reloading accounts.json - E2E - - List and verify other users's devices - SAS verification - Request room keys from own other devices - - Auto-trust accounts within the same client - Provide help when undecryptable messages occur, including: - Trigger `nio.AsyncClient.request_room_key` - Option to export-logout-login-import to fix one-time key problems diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 270bc464..9ccf5f8a 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -323,6 +323,8 @@ class MatrixClient(nio.AsyncClient): self.no_unknown_events_filter["room"]["timeline"]["not_types"], ) + await self.auto_verify_all_other_accounts() + while True: try: self.sync_task = asyncio.ensure_future(self.sync_forever( @@ -1381,6 +1383,32 @@ class MatrixClient(nio.AsyncClient): self.blacklist_device(self.device_store[user_id][device_id]) + async def auto_verify_all_other_accounts(self) -> None: + """Automatically verify/blacklist our other accounts's devices.""" + + for client in self.backend.clients.values(): + await self.auto_verify_account(client) + + + async def auto_verify_account(self, client: "MatrixClient") -> None: + """Automatically verify/blacklist one of our accounts's devices.""" + + if client.user_id == self.user_id: + return + + for device in self.device_store.active_user_devices(client.user_id): + if device.device_id != client.device_id: + continue + + if device.verified or device.blacklisted: + continue + + if device.ed25519 == client.olm.account.identity_keys["ed25519"]: + self.verify_device(device) + else: + self.blacklist_device(device) + + async def delete_devices_with_password( self, device_ids: List[str], password: str, ) -> None: diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index dcf7c276..084b3169 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -109,12 +109,16 @@ class NioCallbacks: async def onKeysQueryResponse(self, resp: nio.KeysQueryResponse) -> None: refresh_rooms = {} + clients = self.client.backend.clients for user_id in resp.changed: for room in self.client.rooms.values(): if user_id in room.users: refresh_rooms[room.room_id] = room + if user_id != self.user_id and user_id in clients: + await self.client.auto_verify_account(clients[user_id]) + for room_id, room in refresh_rooms.items(): room_item = self.models[self.user_id, "rooms"].get(room_id)