Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5355 from matrix-org/babolivier/heroes_left_members
Browse files Browse the repository at this point in the history
Include left members in room summaries' heroes
  • Loading branch information
babolivier authored Jun 6, 2019
2 parents 99d3497 + 804f26a commit b9c43c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog.d/5355.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include left members in room summaries' heroes.
34 changes: 19 additions & 15 deletions synapse/handlers/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,28 @@ def compute_summary(self, room_id, sync_config, batch, state, now_token):
if canonical_alias and canonical_alias.content:
defer.returnValue(summary)

me = sync_config.user.to_string()

joined_user_ids = [
r[0] for r in details.get(Membership.JOIN, empty_ms).members
r[0]
for r in details.get(Membership.JOIN, empty_ms).members
if r[0] != me
]
invited_user_ids = [
r[0] for r in details.get(Membership.INVITE, empty_ms).members
r[0]
for r in details.get(Membership.INVITE, empty_ms).members
if r[0] != me
]
gone_user_ids = (
[r[0] for r in details.get(Membership.LEAVE, empty_ms).members] +
[r[0] for r in details.get(Membership.BAN, empty_ms).members]
[
r[0]
for r in details.get(Membership.LEAVE, empty_ms).members
if r[0] != me
] + [
r[0]
for r in details.get(Membership.BAN, empty_ms).members
if r[0] != me
]
)

# FIXME: only build up a member_ids list for our heroes
Expand All @@ -621,22 +634,13 @@ def compute_summary(self, room_id, sync_config, batch, state, now_token):
member_ids[user_id] = event_id

# FIXME: order by stream ordering rather than as returned by SQL
me = sync_config.user.to_string()
if (joined_user_ids or invited_user_ids):
summary['m.heroes'] = sorted(
[
user_id
for user_id in (joined_user_ids + invited_user_ids)
if user_id != me
]
[user_id for user_id in (joined_user_ids + invited_user_ids)]
)[0:5]
else:
summary['m.heroes'] = sorted(
[
user_id
for user_id in gone_user_ids
if user_id != me
]
[user_id for user_id in gone_user_ids]
)[0:5]

if not sync_config.filter_collection.lazy_load_members():
Expand Down

0 comments on commit b9c43c8

Please sign in to comment.