瀏覽代碼

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 <mathieuv@matrix.org>
Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
tags/v1.69.0rc1
Mathieu Velten 1 年之前
committed by GitHub
父節點
當前提交
41461fd4d6
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 3 個文件被更改,包括 10 次插入2 次删除
  1. +1
    -0
      changelog.d/13830.bugfix
  2. +5
    -2
      synapse/handlers/typing.py
  3. +4
    -0
      tests/handlers/test_typing.py

+ 1
- 0
changelog.d/13830.bugfix 查看文件

@@ -0,0 +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.

+ 5
- 2
synapse/handlers/typing.py 查看文件

@@ -362,11 +362,14 @@ class TypingWriterHandler(FollowerTypingHandler):
) )
return return


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


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


+ 4
- 0
tests/handlers/test_typing.py 查看文件

@@ -138,6 +138,10 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
get_current_hosts_in_room get_current_hosts_in_room
) )


hs.get_storage_controllers().state.get_current_hosts_in_room_or_partial_state_approximation = (
get_current_hosts_in_room
)

async def get_users_in_room(room_id: str): async def get_users_in_room(room_id: str):
return {str(u) for u in self.room_members} return {str(u) for u in self.room_members}




Loading…
取消
儲存