Auto-verify/blacklist accounts within same client

This commit is contained in:
miruka 2020-07-09 12:27:47 -04:00
parent 9edfba8f18
commit b0e2533bb9
3 changed files with 34 additions and 3 deletions

View File

@ -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

View File

@ -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:

View File

@ -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)