diff options
author | Matthew Hodgson <matthew@matrix.org> | 2018-09-18 10:58:04 +0100 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2018-09-18 10:58:04 +0100 |
commit | 5aaa252eb37ba1359f19d4c15961ab754f81078a (patch) | |
tree | 14c6c94008f55c9b95e1f2f77468de17ed23ebc5 /synapse/handlers | |
parent | Merge pull request #3892 from matrix-org/rav/decode_bytes_in_request_logs (diff) | |
download | synapse-5aaa252eb37ba1359f19d4c15961ab754f81078a.tar.xz |
always calculate heroes for rooms without avatars
so that clients can synthesise a room avatar from the heroes' one(s) if needed.
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/sync.py | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 9bca4e7067..ee2eab42e7 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -548,9 +548,6 @@ class SyncHandler(object): # this is heavily cached, thus: fast. details = yield self.store.get_room_summary(room_id) - name_id = state_ids.get((EventTypes.Name, '')) - canonical_alias_id = state_ids.get((EventTypes.CanonicalAlias, '')) - summary = {} empty_ms = MemberSummary([], 0) @@ -562,21 +559,31 @@ class SyncHandler(object): details.get(Membership.INVITE, empty_ms).count ) - # if the room has a name or canonical_alias set, we can skip - # calculating heroes. we assume that if the event has contents, it'll + # if the room has no avatar, we need to calculate heroes. + # otherwise, if the room has a name or canonical_alias set, we can skip + # calculating heroes. + # we assume that if the event has contents, it'll # be a valid name or canonical_alias - i.e. we're checking that they # haven't been "deleted" by blatting {} over the top. - if name_id: - name = yield self.store.get_event(name_id, allow_none=False) - if name and name.content: - defer.returnValue(summary) - - if canonical_alias_id: - canonical_alias = yield self.store.get_event( - canonical_alias_id, allow_none=False, - ) - if canonical_alias and canonical_alias.content: - defer.returnValue(summary) + room_avatar_id = state_ids.get((EventTypes.RoomAvatar, '')) + if room_avatar_id: + room_avatar = yield self.store.get_event(room_avatar_id, allow_none=False) + if room_avatar and room_avatar.content: + # we have a room avatar; check to see if we can skip heroes + # because the room has an explicit name or canonical alias: + name_id = state_ids.get((EventTypes.Name, '')) + if name_id: + name = yield self.store.get_event(name_id, allow_none=False) + if name and name.content: + defer.returnValue(summary) + + canonical_alias_id = state_ids.get((EventTypes.CanonicalAlias, '')) + if canonical_alias_id: + canonical_alias = yield self.store.get_event( + canonical_alias_id, allow_none=False, + ) + if canonical_alias and canonical_alias.content: + defer.returnValue(summary) joined_user_ids = [ r[0] for r in details.get(Membership.JOIN, empty_ms).members |