-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Correctly create power level event during initial room creation #14361
Changes from 6 commits
fd20000
87b3e3c
1634163
1796777
2123135
4c458ea
7b0ba19
2b3f55c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a bug introduced in #14228 where the power level event was incorrectly created during initial room creation. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1139,13 +1139,21 @@ async def create_event( | |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this bool seems to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added a docstring, let me know if it makes more sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, but maybe would benefit from an elaboration about what the difference is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added some elaboration, hopefully it is clearer. |
||
) | ||
current_state_group = power_context._state_group | ||
events_to_send.append((power_event, power_context)) | ||
|
@@ -1194,7 +1202,7 @@ async def create_event( | |
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)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was the bug ever released?
If so, cite the version number instead.
If not, probably just coalesce the changelogs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was released in most recent rc. I've updated the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, is it serious enough to go into the release branch?
Actually it occurs to me that I don't understand what 'the power level event was incorrectly created' means — at first thought this sounds like the power levels event wasn't meant to be created, but surely that can't be right.
Iit would be best to note the user-visible bug if there is one. I honestly have lost track of this over the weekend so I'm afraid I can't remember enough to advise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There isn't an end-user facing bug afaict. From my understanding, the worst thing that could happen with this bug is the code could break unexpectedly if other changes were made to the surrounding code, so mostly fixing this is to a: prevent confusion in the future and b: set up the code for further changes (such as adding the membership event to the batch or batching up state groups).