mirror of
https://github.com/element-hq/synapse
synced 2024-10-01 21:32:40 +00:00
Simplify boolean logic and avoid set construction
See https://github.com/element-hq/synapse/pull/17187#discussion_r1629853770
This commit is contained in:
parent
0153a6e535
commit
6f10b9722d
1 changed files with 7 additions and 8 deletions
|
@ -53,14 +53,13 @@ def filter_membership_for_sync(*, membership: str, user_id: str, sender: str) ->
|
||||||
sender: The person who sent the membership event
|
sender: The person who sent the membership event
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return (
|
# Everything except `Membership.LEAVE` because we want everything that's *still*
|
||||||
# Everything except `Membership.LEAVE` because we want everything that's *still*
|
# relevant to the user. There are few more things to include in the sync response
|
||||||
# relevant to the user. There are few more things to include in the sync response
|
# (newly_left) but those are handled separately.
|
||||||
# (newly_left) but those are handled separately.
|
#
|
||||||
membership in (Membership.LIST - {Membership.LEAVE})
|
# This logic includes kicks (leave events where the sender is not the same user) and
|
||||||
# Include kicks
|
# can be read as "anything that isn't a leave or a leave with a different sender".
|
||||||
or (membership == Membership.LEAVE and sender != user_id)
|
return membership != Membership.LEAVE or sender != user_id
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SlidingSyncConfig(SlidingSyncBody):
|
class SlidingSyncConfig(SlidingSyncBody):
|
||||||
|
|
Loading…
Reference in a new issue