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

Commit 41461fd

Browse files
Mathieu Veltensquahtx
Mathieu Velten
andauthored
typing: check origin server of typing event against room's servers (#13830)
This is also using the partial state approximation if needed so we do not block here during a fast join. Signed-off-by: Mathieu Velten <[email protected]> Co-authored-by: Sean Quah <[email protected]>
1 parent 6b4593a commit 41461fd

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

changelog.d/13830.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a long-standing bug where typing events would be accepted from remote servers not present in a room. Also fix a bug where incoming typing events would cause other incoming events to get stuck during a fast join.

synapse/handlers/typing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,14 @@ async def _recv_edu(self, origin: str, content: JsonDict) -> None:
362362
)
363363
return
364364

365-
domains = await self._storage_controllers.state.get_current_hosts_in_room(
365+
# Let's check that the origin server is in the room before accepting the typing
366+
# event. We don't want to block waiting on a partial state so take an
367+
# approximation if needed.
368+
domains = await self._storage_controllers.state.get_current_hosts_in_room_or_partial_state_approximation(
366369
room_id
367370
)
368371

369-
if self.server_name in domains:
372+
if user.domain in domains:
370373
logger.info("Got typing update from %s: %r", user_id, content)
371374
now = self.clock.time_msec()
372375
self._member_typing_until[member] = now + FEDERATION_TIMEOUT

tests/handlers/test_typing.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ async def get_current_hosts_in_room(room_id: str):
138138
get_current_hosts_in_room
139139
)
140140

141+
hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = (
142+
get_current_hosts_in_room
143+
)
144+
141145
async def get_users_in_room(room_id: str):
142146
return {str(u) for u in self.room_members}
143147

0 commit comments

Comments
 (0)