diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-20 13:21:59 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-20 13:21:59 +0100 |
commit | e01b825cc929e16b6a60be0688bbe6d8d9b3866e (patch) | |
tree | 6e0ec87e9bf6e7c5f4e6007ed0eefddc05da06a0 | |
parent | Speed up the get_pagination_rows as well (diff) | |
download | synapse-e01b825cc929e16b6a60be0688bbe6d8d9b3866e.tar.xz |
Clean up the presence_list checking logic a bit
Diffstat (limited to '')
-rw-r--r-- | synapse/handlers/presence.py | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index 6537a37385..226d6a0f51 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1084,14 +1084,14 @@ class PresenceEventSource(object): clock = self.clock latest_serial = 0 + user_ids_to_check = {user} presence_list = yield presence.store.get_presence_list( user.localpart, accepted=True ) - if presence_list is None: - presence_list = () - user_ids_to_check = set( - UserID.from_string(p["observed_user_id"]) for p in presence_list - ) + if presence_list is not None: + user_ids_to_check |= set( + UserID.from_string(p["observed_user_id"]) for p in presence_list + ) room_ids = yield presence.get_joined_rooms_for_user(user) for room_id in set(room_ids) & set(presence._room_serials): if presence._room_serials[room_id] > from_key: @@ -1142,8 +1142,6 @@ class PresenceEventSource(object): def get_pagination_rows(self, user, pagination_config, key): # TODO (erikj): Does this make sense? Ordering? - observer_user = user - from_key = int(pagination_config.from_key) if pagination_config.to_key: @@ -1158,11 +1156,10 @@ class PresenceEventSource(object): presence_list = yield presence.store.get_presence_list( user.localpart, accepted=True ) - if presence_list is None: - presence_list = () - user_ids_to_check |= set( - UserID.from_string(p["observed_user_id"]) for p in presence_list - ) + if presence_list is not None: + user_ids_to_check |= set( + UserID.from_string(p["observed_user_id"]) for p in presence_list + ) room_ids = yield presence.get_joined_rooms_for_user(user) for room_id in set(room_ids) & set(presence._room_serials): if presence._room_serials[room_id] >= from_key: |