|
@@ -25,6 +25,8 @@ The methods that define policy are:
|
|
|
from twisted.internet import defer, reactor
|
|
|
from contextlib import contextmanager
|
|
|
|
|
|
+from six import itervalues, iteritems
|
|
|
+
|
|
|
from synapse.api.errors import SynapseError
|
|
|
from synapse.api.constants import PresenceState
|
|
|
from synapse.storage.presence import UserPresenceState
|
|
@@ -40,7 +42,6 @@ import synapse.metrics
|
|
|
|
|
|
import logging
|
|
|
|
|
|
-
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
metrics = synapse.metrics.get_metrics_for(__name__)
|
|
@@ -526,7 +527,7 @@ class PresenceHandler(object):
|
|
|
prev_state.copy_and_replace(
|
|
|
last_user_sync_ts=time_now_ms,
|
|
|
)
|
|
|
- for prev_state in prev_states.itervalues()
|
|
|
+ for prev_state in itervalues(prev_states)
|
|
|
])
|
|
|
self.external_process_last_updated_ms.pop(process_id, None)
|
|
|
|
|
@@ -549,14 +550,14 @@ class PresenceHandler(object):
|
|
|
for user_id in user_ids
|
|
|
}
|
|
|
|
|
|
- missing = [user_id for user_id, state in states.iteritems() if not state]
|
|
|
+ missing = [user_id for user_id, state in iteritems(states) if not state]
|
|
|
if missing:
|
|
|
# There are things not in our in memory cache. Lets pull them out of
|
|
|
# the database.
|
|
|
res = yield self.store.get_presence_for_users(missing)
|
|
|
states.update(res)
|
|
|
|
|
|
- missing = [user_id for user_id, state in states.iteritems() if not state]
|
|
|
+ missing = [user_id for user_id, state in iteritems(states) if not state]
|
|
|
if missing:
|
|
|
new = {
|
|
|
user_id: UserPresenceState.default(user_id)
|
|
@@ -1044,7 +1045,7 @@ class PresenceEventSource(object):
|
|
|
defer.returnValue((updates.values(), max_token))
|
|
|
else:
|
|
|
defer.returnValue(([
|
|
|
- s for s in updates.itervalues()
|
|
|
+ s for s in itervalues(updates)
|
|
|
if s.state != PresenceState.OFFLINE
|
|
|
], max_token))
|
|
|
|
|
@@ -1301,11 +1302,11 @@ def get_interested_remotes(store, states, state_handler):
|
|
|
# hosts in those rooms.
|
|
|
room_ids_to_states, users_to_states = yield get_interested_parties(store, states)
|
|
|
|
|
|
- for room_id, states in room_ids_to_states.iteritems():
|
|
|
+ for room_id, states in iteritems(room_ids_to_states):
|
|
|
hosts = yield state_handler.get_current_hosts_in_room(room_id)
|
|
|
hosts_and_states.append((hosts, states))
|
|
|
|
|
|
- for user_id, states in users_to_states.iteritems():
|
|
|
+ for user_id, states in iteritems(users_to_states):
|
|
|
host = get_domain_from_id(user_id)
|
|
|
hosts_and_states.append(([host], states))
|
|
|
|