-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove backwards-compatibility code for access tokens without an associated device #11829
Description
I ran into this while implementing #11215.
Before #949, it was possible to have access tokens that were not associated with a device. This has now been deprecated for 5 years.
This possibility has now crept across the codebase, as we've marked device_id
as Optional
in many places, including:
synapse/synapse/handlers/sync.py
Lines 87 to 93 in d4e6f35
@attr.s(slots=True, frozen=True, auto_attribs=True) | |
class SyncConfig: | |
user: UserID | |
filter_collection: FilterCollection | |
is_guest: bool | |
request_key: SyncRequestKey | |
device_id: str |
This makes little sense, as you're expected to have a device if you're calling /sync
. Much of the /sync
handling code assumes you have a device, and would logically fail if the user didn't:
synapse/synapse/storage/databases/main/deviceinbox.py
Lines 199 to 201 in 3e0536c
async def delete_messages_for_device( | |
self, user_id: str, device_id: Optional[str], up_to_stream_id: int | |
) -> int: |
Passing device_id=None
to this function always results in zero to-device messages being returned.
Is there anything holding us back (old access tokens?) from marking device IDs as str
, not Optional[str]
?
Edit: There are currently 64
entries in the access_tokens
table on matrix.org that do not have an associated device ID. They are all either abuse, or go neb...