diff options
author | Erik Johnston <erik@matrix.org> | 2019-05-09 13:21:57 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-05-14 11:58:01 +0100 |
commit | b54b03f9e1abc1964fe5f00115a165a2b8e10df5 (patch) | |
tree | bb2a357af902fbdfa935da416a6beaedbd5c8a02 /synapse/handlers/pagination.py | |
parent | Migrate all tests to use the dict-based config format instead of hanging item... (diff) | |
download | synapse-b54b03f9e1abc1964fe5f00115a165a2b8e10df5.tar.xz |
Allow client event serialization to be async
Diffstat (limited to 'synapse/handlers/pagination.py')
-rw-r--r-- | synapse/handlers/pagination.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index e4fdae9266..8f811e24fe 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -20,7 +20,6 @@ from twisted.python.failure import Failure from synapse.api.constants import EventTypes, Membership from synapse.api.errors import SynapseError -from synapse.events.utils import serialize_event from synapse.storage.state import StateFilter from synapse.types import RoomStreamToken from synapse.util.async_helpers import ReadWriteLock @@ -78,6 +77,7 @@ class PaginationHandler(object): self._purges_in_progress_by_room = set() # map from purge id to PurgeStatus self._purges_by_id = {} + self._event_serializer = hs.get_event_client_serializer() def start_purge_history(self, room_id, token, delete_local_events=False): @@ -278,18 +278,22 @@ class PaginationHandler(object): time_now = self.clock.time_msec() chunk = { - "chunk": [ - serialize_event(e, time_now, as_client_event) - for e in events - ], + "chunk": ( + yield self._event_serializer.serialize_events( + events, time_now, + as_client_event=as_client_event, + ) + ), "start": pagin_config.from_token.to_string(), "end": next_token.to_string(), } if state: - chunk["state"] = [ - serialize_event(e, time_now, as_client_event) - for e in state - ] + chunk["state"] = ( + yield self._event_serializer.serialize_events( + state, time_now, + as_client_event=as_client_event, + ) + ) defer.returnValue(chunk) |