diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2022-01-25 18:23:21 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2022-01-25 18:23:21 +0000 |
commit | d4e6f358b64b340a670e4f7496a530c11a715920 (patch) | |
tree | 714f7a92952f86048fab58ec0e43ad14ead1f39d | |
parent | Add admin API to get a list of federated rooms (#11658) (diff) | |
download | synapse-anoa/deprecate_no_device_access_tokens.tar.xz |
Require device_id in SyncConfig github/anoa/deprecate_no_device_access_tokens anoa/deprecate_no_device_access_tokens
You should always have a device if you're syncing
-rw-r--r-- | synapse/handlers/sync.py | 6 | ||||
-rw-r--r-- | synapse/rest/client/sync.py | 3 | ||||
-rw-r--r-- | synapse/storage/databases/main/deviceinbox.py | 4 | ||||
-rw-r--r-- | tests/handlers/test_sync.py | 2 |
4 files changed, 9 insertions, 6 deletions
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 7e2a892b63..dcb720dcf7 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -90,7 +90,7 @@ class SyncConfig: filter_collection: FilterCollection is_guest: bool request_key: SyncRequestKey - device_id: Optional[str] + device_id: str @attr.s(slots=True, frozen=True, auto_attribs=True) @@ -288,7 +288,7 @@ class SyncHandler: # ExpiringCache((User, Device)) -> LruCache(user_id => event_id) self.lazy_loaded_members_cache: ExpiringCache[ - Tuple[str, Optional[str]], LruCache[str, str] + Tuple[str, str], LruCache[str, str] ] = ExpiringCache( "lazy_loaded_members_cache", self.clock, @@ -833,7 +833,7 @@ class SyncHandler: return summary def get_lazy_loaded_members_cache( - self, cache_key: Tuple[str, Optional[str]] + self, cache_key: Tuple[str, str] ) -> LruCache[str, str]: cache: Optional[LruCache[str, str]] = self.lazy_loaded_members_cache.get( cache_key diff --git a/synapse/rest/client/sync.py b/synapse/rest/client/sync.py index d20ae1421e..5fedc1d133 100644 --- a/synapse/rest/client/sync.py +++ b/synapse/rest/client/sync.py @@ -125,6 +125,9 @@ class SyncRestServlet(RestServlet): user = requester.user device_id = requester.device_id + # We must have a device ID, as this request is authenticated. + assert device_id + timeout = parse_integer(request, "timeout", default=0) since = parse_string(request, "since") set_presence = parse_string( diff --git a/synapse/storage/databases/main/deviceinbox.py b/synapse/storage/databases/main/deviceinbox.py index 4eca97189b..d4a5726061 100644 --- a/synapse/storage/databases/main/deviceinbox.py +++ b/synapse/storage/databases/main/deviceinbox.py @@ -139,7 +139,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): async def get_new_messages_for_device( self, user_id: str, - device_id: Optional[str], + device_id: str, last_stream_id: int, current_stream_id: int, limit: int = 100, @@ -197,7 +197,7 @@ class DeviceInboxWorkerStore(SQLBaseStore): @trace async def delete_messages_for_device( - self, user_id: str, device_id: Optional[str], up_to_stream_id: int + self, user_id: str, device_id: str, up_to_stream_id: int ) -> int: """ Args: diff --git a/tests/handlers/test_sync.py b/tests/handlers/test_sync.py index 07a760e91a..95026e82c4 100644 --- a/tests/handlers/test_sync.py +++ b/tests/handlers/test_sync.py @@ -282,7 +282,7 @@ _request_key = 0 def generate_sync_config( - user_id: str, device_id: Optional[str] = "device_id" + user_id: str, device_id: str = "device_id" ) -> SyncConfig: """Generate a sync config (with a unique request key).""" global _request_key |