|
|
@ -1154,13 +1154,27 @@ class PresenceEventSource(object): |
|
|
|
presence = self.hs.get_handlers().presence_handler |
|
|
|
presence = self.hs.get_handlers().presence_handler |
|
|
|
cachemap = presence._user_cachemap |
|
|
|
cachemap = presence._user_cachemap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
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: |
|
|
|
|
|
|
|
joined = yield presence.get_joined_users_for_room_id(room_id) |
|
|
|
|
|
|
|
user_ids_to_check |= set(joined) |
|
|
|
|
|
|
|
|
|
|
|
updates = [] |
|
|
|
updates = [] |
|
|
|
# TODO(paul): use a DeferredList ? How to limit concurrency. |
|
|
|
# TODO(paul): use a DeferredList ? How to limit concurrency. |
|
|
|
for observed_user in cachemap.keys(): |
|
|
|
for observed_user in user_ids_to_check & set(cachemap): |
|
|
|
if not (to_key < cachemap[observed_user].serial <= from_key): |
|
|
|
if not (to_key < cachemap[observed_user].serial <= from_key): |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if (yield self.is_visible(observer_user, observed_user)): |
|
|
|
|
|
|
|
updates.append((observed_user, cachemap[observed_user])) |
|
|
|
updates.append((observed_user, cachemap[observed_user])) |
|
|
|
|
|
|
|
|
|
|
|
# TODO(paul): limit |
|
|
|
# TODO(paul): limit |
|
|
|