mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 09:34:13 -04:00
Make token serializing/deserializing async (#8427)
The idea is that in future tokens will encode a mapping of instance to position. However, we don't want to include the full instance name in the string representation, so instead we'll have a mapping between instance name and an immutable integer ID in the DB that we can use instead. We'll then do the lookup when we serialize/deserialize the token (we could alternatively pass around an `Instance` type that includes both the name and ID, but that turns out to be a lot more invasive).
This commit is contained in:
parent
a0a1ba6973
commit
7941372ec8
17 changed files with 115 additions and 59 deletions
|
@ -77,6 +77,7 @@ class SyncRestServlet(RestServlet):
|
|||
super().__init__()
|
||||
self.hs = hs
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastore()
|
||||
self.sync_handler = hs.get_sync_handler()
|
||||
self.clock = hs.get_clock()
|
||||
self.filtering = hs.get_filtering()
|
||||
|
@ -151,10 +152,9 @@ class SyncRestServlet(RestServlet):
|
|||
device_id=device_id,
|
||||
)
|
||||
|
||||
since_token = None
|
||||
if since is not None:
|
||||
since_token = StreamToken.from_string(since)
|
||||
else:
|
||||
since_token = None
|
||||
since_token = await StreamToken.from_string(self.store, since)
|
||||
|
||||
# send any outstanding server notices to the user.
|
||||
await self._server_notices_sender.on_user_syncing(user.to_string())
|
||||
|
@ -236,7 +236,7 @@ class SyncRestServlet(RestServlet):
|
|||
"leave": sync_result.groups.leave,
|
||||
},
|
||||
"device_one_time_keys_count": sync_result.device_one_time_keys_count,
|
||||
"next_batch": sync_result.next_batch.to_string(),
|
||||
"next_batch": await sync_result.next_batch.to_string(self.store),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
|
@ -413,7 +413,7 @@ class SyncRestServlet(RestServlet):
|
|||
result = {
|
||||
"timeline": {
|
||||
"events": serialized_timeline,
|
||||
"prev_batch": room.timeline.prev_batch.to_string(),
|
||||
"prev_batch": await room.timeline.prev_batch.to_string(self.store),
|
||||
"limited": room.timeline.limited,
|
||||
},
|
||||
"state": {"events": serialized_state},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue