Merge branch 'erikj/faster_typing' of github.com:matrix-org/synapse into develop

This commit is contained in:
Erik Johnston 2020-07-15 16:54:30 +01:00
commit 97e1159ac1
3 changed files with 5 additions and 4 deletions

1
changelog.d/7856.misc Normal file
View file

@ -0,0 +1 @@
Small performance improvement in typing processing.

View file

@ -185,7 +185,7 @@ class TypingHandler(object):
async def _push_remote(self, member, typing): async def _push_remote(self, member, typing):
try: try:
users = await self.state.get_current_users_in_room(member.room_id) users = await self.store.get_users_in_room(member.room_id)
self._member_last_federation_poke[member] = self.clock.time_msec() self._member_last_federation_poke[member] = self.clock.time_msec()
now = self.clock.time_msec() now = self.clock.time_msec()
@ -224,7 +224,7 @@ class TypingHandler(object):
) )
return return
users = await self.state.get_current_users_in_room(room_id) users = await self.store.get_users_in_room(room_id)
domains = {get_domain_from_id(u) for u in users} domains = {get_domain_from_id(u) for u in users}
if self.server_name in domains: if self.server_name in domains:

View file

@ -138,10 +138,10 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
self.datastore.get_joined_hosts_for_room = get_joined_hosts_for_room self.datastore.get_joined_hosts_for_room = get_joined_hosts_for_room
def get_current_users_in_room(room_id): def get_users_in_room(room_id):
return defer.succeed({str(u) for u in self.room_members}) return defer.succeed({str(u) for u in self.room_members})
hs.get_state_handler().get_current_users_in_room = get_current_users_in_room self.datastore.get_users_in_room = get_users_in_room
self.datastore.get_user_directory_stream_pos.return_value = ( self.datastore.get_user_directory_stream_pos.return_value = (
# we deliberately return a non-None stream pos to avoid doing an initial_spam # we deliberately return a non-None stream pos to avoid doing an initial_spam