diff options
author | Eric Eastwood <erice@element.io> | 2021-09-29 18:51:08 -0500 |
---|---|---|
committer | Eric Eastwood <erice@element.io> | 2021-09-29 18:51:08 -0500 |
commit | 4fea37ed06516b1cff4838833578f796bb35e709 (patch) | |
tree | 2a63026278c9e158dab49027e86510d7a888190a | |
parent | Only generate context when we need to (it's not free to throw away) (diff) | |
download | synapse-4fea37ed06516b1cff4838833578f796bb35e709.tar.xz |
Add proper state and state_groups so historical events return state from /context
See https://gitlab.com/gitterHQ/webapp/-/merge_requests/2229#note_683532091 Also seems to fix https://github.com/matrix-org/synapse/issues/10764
-rw-r--r-- | synapse/handlers/message.py | 10 | ||||
-rw-r--r-- | synapse/rest/client/room_batch.py | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py index d69eb32f41..79799d774f 100644 --- a/synapse/handlers/message.py +++ b/synapse/handlers/message.py @@ -959,7 +959,15 @@ class EventCreationHandler: event.internal_metadata.outlier = True context = EventContext.for_outlier() else: - context = await self.state.compute_event_context(event) + old_state = None + # Define the state for historical messages while we know to get all of + # state_groups setup properly when we `compute_event_context`. + if builder.internal_metadata.is_historical() and auth_event_ids: + old_state = await self.store.get_events_as_list(auth_event_ids) + + context = await self.state.compute_event_context(event, old_state=old_state) + + logger.info("create_new_client_event type=%s, event_id=%s context=%s", event.type, event.event_id, context) if requester: context.app_service = requester.app_service diff --git a/synapse/rest/client/room_batch.py b/synapse/rest/client/room_batch.py index 1dffcc3147..ab5460fc06 100644 --- a/synapse/rest/client/room_batch.py +++ b/synapse/rest/client/room_batch.py @@ -176,6 +176,8 @@ class RoomBatchSendEventRestServlet(RestServlet): async def on_POST( self, request: SynapseRequest, room_id: str ) -> Tuple[int, JsonDict]: + logger.info("room batch send =====================================================") + logger.info("=====================================================================") requester = await self.auth.get_user_by_req(request, allow_guest=False) if not requester.app_service: |