diff options
author | Erik Johnston <erik@matrix.org> | 2020-01-28 14:43:21 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-28 14:43:21 +0000 |
commit | e17a11066192354f6c6144135a14e7abe524f44c (patch) | |
tree | 45ee5996c7b1b6c5078eceb4127d2d9aa1fa017b /synapse/handlers/federation.py | |
parent | Pass room version object into event_auth.check and check_redaction (#6788) (diff) | |
download | synapse-e17a11066192354f6c6144135a14e7abe524f44c.tar.xz |
Detect unknown remote devices and mark cache as stale (#6776)
We just mark the fact that the cache may be stale in the database for now.
Diffstat (limited to 'synapse/handlers/federation.py')
-rw-r--r-- | synapse/handlers/federation.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py index 180f165a7a..a67020a259 100644 --- a/synapse/handlers/federation.py +++ b/synapse/handlers/federation.py @@ -742,6 +742,26 @@ class FederationHandler(BaseHandler): user = UserID.from_string(event.state_key) await self.user_joined_room(user, room_id) + # For encrypted messages we check that we know about the sending device, + # if we don't then we mark the device cache for that user as stale. + if event.type == EventTypes.Encryption: + device_id = event.content.get("device_id") + if device_id is not None: + cached_devices = await self.store.get_cached_devices_for_user( + event.sender + ) + if device_id not in cached_devices: + logger.info( + "Received event from remote device not in our cache: %s %s", + event.sender, + device_id, + ) + await self.store.mark_remote_user_device_cache_as_stale( + event.sender + ) + # TODO: Poke something to start trying to refetch user's + # keys. + @log_function async def backfill(self, dest, room_id, limit, extremities): """ Trigger a backfill request to `dest` for the given `room_id` |