Merge pull request #5355 from matrix-org/babolivier/heroes_left_members

Include left members in room summaries' heroes
pull/5369/head
Brendan Abolivier 2019-06-06 10:05:27 +01:00 committed by GitHub
commit b9c43c8463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 15 deletions

1
changelog.d/5355.bugfix Normal file
View File

@ -0,0 +1 @@
Include left members in room summaries' heroes.

View File

@ -598,15 +598,28 @@ class SyncHandler(object):
if canonical_alias and canonical_alias.content: if canonical_alias and canonical_alias.content:
defer.returnValue(summary) defer.returnValue(summary)
me = sync_config.user.to_string()
joined_user_ids = [ 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 = [ 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 = ( 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 # FIXME: only build up a member_ids list for our heroes
@ -621,22 +634,13 @@ class SyncHandler(object):
member_ids[user_id] = event_id member_ids[user_id] = event_id
# FIXME: order by stream ordering rather than as returned by SQL # 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): if (joined_user_ids or invited_user_ids):
summary['m.heroes'] = sorted( summary['m.heroes'] = sorted(
[ [user_id for user_id in (joined_user_ids + invited_user_ids)]
user_id
for user_id in (joined_user_ids + invited_user_ids)
if user_id != me
]
)[0:5] )[0:5]
else: else:
summary['m.heroes'] = sorted( summary['m.heroes'] = sorted(
[ [user_id for user_id in gone_user_ids]
user_id
for user_id in gone_user_ids
if user_id != me
]
)[0:5] )[0:5]
if not sync_config.filter_collection.lazy_load_members(): if not sync_config.filter_collection.lazy_load_members():