From 6536f89507ca868ee2d217831c58c15527a5a0ae Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 9 Apr 2020 05:52:33 -0400 Subject: [PATCH] Fix missing rooms and wrong avatars in initialsync --- src/backend/matrix_client.py | 14 ++++++++------ src/backend/nio_callbacks.py | 8 ++++++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 62f31df4..5c25713f 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -98,14 +98,16 @@ class MatrixClient(nio.AsyncClient): } limit_1_filter: ClassVar[Dict[str, Any]] = { - "presence": {"limit": 1}, - "account_data": {"limit": 1}, + "presence": {"limit": 1}, "room": { - "ephemeral": {"limit": 1}, - "state": {"limit": 1}, - "timeline": {"limit": 1}, - "account_data": {"limit": 1}, + "ephemeral": {"limit": 1}, + "timeline": { + "limit": 1, + # This kind says another event was redacted, but we wouldn't + # have it in our model, so nothing would be shown + "not_types": ["m.room.redaction"], + }, }, } diff --git a/src/backend/nio_callbacks.py b/src/backend/nio_callbacks.py index 55973805..4d901a86 100644 --- a/src/backend/nio_callbacks.py +++ b/src/backend/nio_callbacks.py @@ -56,7 +56,14 @@ class NioCallbacks: # Response callbacks async def onSyncResponse(self, resp: nio.SyncResponse) -> None: + room_model = self.client.models[self.client.user_id, "rooms"] + for room_id, info in resp.rooms.join.items(): + if room_id not in room_model: + # Just in case we don't get any events for that room that + # triggers other callbacks + await self.client.register_nio_room(self.client.rooms[room_id]) + if room_id not in self.client.past_tokens: self.client.past_tokens[room_id] = info.timeline.prev_batch @@ -165,6 +172,7 @@ class NioCallbacks: event and (event.event_type is not nio.RedactedEvent or event.is_local_echo) ): + await self.client.register_nio_room(room) return event.source.source["content"] = {}