Merge remote-tracking branch 'upstream/release-v1.72'

This commit is contained in:
Tulir Asokan 2022-11-16 17:51:05 +02:00
commit 108a80e9b0
113 changed files with 2633 additions and 1258 deletions

View file

@ -1092,6 +1092,19 @@ class RoomCreationHandler:
for_batch: bool,
**kwargs: Any,
) -> Tuple[EventBase, synapse.events.snapshot.EventContext]:
"""
Creates an event and associated event context.
Args:
etype: the type of event to be created
content: content of the event
for_batch: whether the event is being created for batch persisting. If
bool for_batch is true, this will create an event using the prev_event_ids,
and will create an event context for the event using the parameters state_map
and current_state_group, thus these parameters must be provided in this
case if for_batch is True. The subsequently created event and context
are suitable for being batched up and bulk persisted to the database
with other similarly created events.
"""
nonlocal depth
nonlocal prev_event
@ -1151,13 +1164,21 @@ class RoomCreationHandler:
depth += 1
state_map[(EventTypes.Member, creator.user.to_string())] = member_event_id
# we need the state group of the membership event as it is the current state group
event_to_state = (
await self._storage_controllers.state.get_state_group_for_events(
[member_event_id]
)
)
current_state_group = event_to_state[member_event_id]
events_to_send = []
# We treat the power levels override specially as this needs to be one
# of the first events that get sent into a room.
pl_content = initial_state.pop((EventTypes.PowerLevels, ""), None)
if pl_content is not None:
power_event, power_context = await create_event(
EventTypes.PowerLevels, pl_content, False
EventTypes.PowerLevels, pl_content, True
)
current_state_group = power_context._state_group
events_to_send.append((power_event, power_context))
@ -1206,7 +1227,7 @@ class RoomCreationHandler:
pl_event, pl_context = await create_event(
EventTypes.PowerLevels,
power_level_content,
False,
True,
)
current_state_group = pl_context._state_group
events_to_send.append((pl_event, pl_context))
@ -1442,7 +1463,7 @@ class RoomContextHandler:
events_before=events_before,
event=event,
events_after=events_after,
state=await filter_evts(state_events),
state=state_events,
aggregations=aggregations,
start=await token.copy_and_replace(
StreamKeyType.ROOM, results.start