Skip to content

Commit 515c1cc

Browse files
Sliding Sync: Add comment to explain extra case where you can be invited -> banned -> unbanned (#17654)
Add comment to explain extra case where you can be invited -> banned -> unbanned and we want to be able to find the invite event. Follow-up to #17636 (comment)
1 parent e1ed959 commit 515c1cc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

changelog.d/17654.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pre-populate room data used in experimental [MSC3575](https://github.com/matrix-org/matrix-spec-proposals/pull/3575) Sliding Sync `/sync` endpoint for quick filtering/sorting.

synapse/storage/databases/main/events_bg_updates.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1966,7 +1966,7 @@ def _find_memberships_to_update_txn(
19661966
)
19671967
return 0
19681968

1969-
def _find_previous_membership_txn(
1969+
def _find_previous_invite_or_knock_membership_txn(
19701970
txn: LoggingTransaction, room_id: str, user_id: str, event_id: str
19711971
) -> Tuple[str, str]:
19721972
# Find the previous invite/knock event before the leave event
@@ -2007,6 +2007,10 @@ def _find_previous_membership_txn(
20072007
(
20082008
room_id,
20092009
user_id,
2010+
# We look explicitly for `invite` and `knock` events instead of
2011+
# just their previous membership as someone could have been `invite`
2012+
# -> `ban` -> unbanned (`leave`) and we want to find the `invite`
2013+
# event where the stripped state is.
20102014
Membership.INVITE,
20112015
Membership.KNOCK,
20122016
event_id,
@@ -2155,8 +2159,8 @@ def _find_previous_membership_txn(
21552159
invite_or_knock_event_id,
21562160
invite_or_knock_membership,
21572161
) = await self.db_pool.runInteraction(
2158-
"sliding_sync_membership_snapshots_bg_update._find_previous_membership",
2159-
_find_previous_membership_txn,
2162+
"sliding_sync_membership_snapshots_bg_update._find_previous_invite_or_knock_membership_txn",
2163+
_find_previous_invite_or_knock_membership_txn,
21602164
room_id,
21612165
user_id,
21622166
membership_event_id,

0 commit comments

Comments
 (0)