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

Commit 7732c49

Browse files
authored
Fix rejecting invites over federation (#12409)
Currently causes future incremental syncs to fail. Broke by #12191
1 parent 36af768 commit 7732c49

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

changelog.d/12409.misc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid trying to calculate the state at outlier events.

synapse/handlers/sync.py

+33-20
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,7 @@ async def _get_rooms_changed(
18511851
full_state=False,
18521852
since_token=since_token,
18531853
upto_token=leave_token,
1854+
out_of_band=leave_event.internal_metadata.is_out_of_band_membership(),
18541855
)
18551856
)
18561857

@@ -2117,33 +2118,41 @@ async def _generate_room_entry(
21172118
):
21182119
return
21192120

2120-
state = await self.compute_state_delta(
2121-
room_id,
2122-
batch,
2123-
sync_config,
2124-
since_token,
2125-
now_token,
2126-
full_state=full_state,
2127-
)
2121+
if not room_builder.out_of_band:
2122+
state = await self.compute_state_delta(
2123+
room_id,
2124+
batch,
2125+
sync_config,
2126+
since_token,
2127+
now_token,
2128+
full_state=full_state,
2129+
)
2130+
else:
2131+
# An out of band room won't have any state changes.
2132+
state = {}
21282133

21292134
summary: Optional[JsonDict] = {}
21302135

21312136
# we include a summary in room responses when we're lazy loading
21322137
# members (as the client otherwise doesn't have enough info to form
21332138
# the name itself).
2134-
if sync_config.filter_collection.lazy_load_members() and (
2135-
# we recalculate the summary:
2136-
# if there are membership changes in the timeline, or
2137-
# if membership has changed during a gappy sync, or
2138-
# if this is an initial sync.
2139-
any(ev.type == EventTypes.Member for ev in batch.events)
2140-
or (
2141-
# XXX: this may include false positives in the form of LL
2142-
# members which have snuck into state
2143-
batch.limited
2144-
and any(t == EventTypes.Member for (t, k) in state)
2139+
if (
2140+
not room_builder.out_of_band
2141+
and sync_config.filter_collection.lazy_load_members()
2142+
and (
2143+
# we recalculate the summary:
2144+
# if there are membership changes in the timeline, or
2145+
# if membership has changed during a gappy sync, or
2146+
# if this is an initial sync.
2147+
any(ev.type == EventTypes.Member for ev in batch.events)
2148+
or (
2149+
# XXX: this may include false positives in the form of LL
2150+
# members which have snuck into state
2151+
batch.limited
2152+
and any(t == EventTypes.Member for (t, k) in state)
2153+
)
2154+
or since_token is None
21452155
)
2146-
or since_token is None
21472156
):
21482157
summary = await self.compute_summary(
21492158
room_id, sync_config, batch, state, now_token
@@ -2387,6 +2396,8 @@ class RoomSyncResultBuilder:
23872396
full_state: Whether the full state should be sent in result
23882397
since_token: Earliest point to return events from, or None
23892398
upto_token: Latest point to return events from.
2399+
out_of_band: whether the events in the room are "out of band" events
2400+
and the server isn't in the room.
23902401
"""
23912402

23922403
room_id: str
@@ -2396,3 +2407,5 @@ class RoomSyncResultBuilder:
23962407
full_state: bool
23972408
since_token: Optional[StreamToken]
23982409
upto_token: StreamToken
2410+
2411+
out_of_band: bool = False

0 commit comments

Comments
 (0)