Compare commits

...

1 Commits

Author SHA1 Message Date
Andrew Morgan
d4e6f358b6 Require device_id in SyncConfig
You should always have a device if you're syncing
2022-01-25 18:23:21 +00:00
4 changed files with 9 additions and 6 deletions

View File

@@ -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

View File

@@ -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(

View File

@@ -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:

View File

@@ -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