Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add proper state and state_groups so historical events return state f…
Browse files Browse the repository at this point in the history
  • Loading branch information
MadLittleMods committed Sep 29, 2021
1 parent fa4f20d commit 4fea37e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,15 @@ async def create_new_client_event(
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
Expand Down
2 changes: 2 additions & 0 deletions synapse/rest/client/room_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ async def _create_requester_for_user_id_from_app_service(
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:
Expand Down

0 comments on commit 4fea37e

Please sign in to comment.