Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Docstring. And small optimisations.
Browse files Browse the repository at this point in the history
  • Loading branch information
JorikSchellekens committed Jul 18, 2019
1 parent 0533ff3 commit 1047e7f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions synapse/handlers/e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
from twisted.internet import defer

from synapse.api.errors import CodeMessageException, SynapseError
from synapse.logging.context import (
LoggingContext,
PreserveLoggingContext,
make_deferred_yieldable,
run_in_background,
)
from synapse.logging.context import make_deferred_yieldable, run_in_background
from synapse.types import UserID, get_domain_from_id
from synapse.util.retryutils import NotRetryingDestination

Expand Down Expand Up @@ -127,6 +122,12 @@ def query_devices(self, query_body, timeout):
# Now fetch any devices that we don't have in our cache
@defer.inlineCallbacks
def do_remote_query(destination):
"""This is called when we are querying the device list of a user on
a remote homeserver and their device list is not in the device list
cache. If we share a room with this user and we're not querying for
specific user we will update the cache
with their device list."""

destination_query = remote_queries_not_in_cache[destination]

# We first consider whether we wish to update the device list cache with
Expand All @@ -140,9 +141,12 @@ def do_remote_query(destination):
for (user_id, device_list) in destination_query.items():
if user_id not in user_ids_updated:
try:
with PreserveLoggingContext(LoggingContext.current_context()):
if not device_list:
room_ids = yield self.store.get_rooms_for_user(user_id)
if not device_list and room_ids:
if room_ids:
# We've decided we're sharing a room with this user and should
# probably be tracking their device lists. However, we haven't
# done an initial sync on the device list so we do it now.
user_devices = yield self.device_handler.device_list_updater.user_device_resync(
user_id
)
Expand Down

0 comments on commit 1047e7f

Please sign in to comment.