Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
72078e4b
Unverified
Commit
72078e4b
authored
5 years ago
by
Andrew Morgan
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Transfer power level state events on room upgrade (#6237)
parent
0ad75fd9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/6237.bugfix
+1
-0
1 addition, 0 deletions
changelog.d/6237.bugfix
synapse/handlers/room.py
+31
-5
31 additions, 5 deletions
synapse/handlers/room.py
with
32 additions
and
5 deletions
changelog.d/6237.bugfix
0 → 100644
+
1
−
0
View file @
72078e4b
Transfer non-standard power levels on room upgrade.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
synapse/handlers/room.py
+
31
−
5
View file @
72078e4b
...
...
@@ -198,21 +198,21 @@ class RoomCreationHandler(BaseHandler):
# finally, shut down the PLs in the old room, and update them in the new
# room.
yield
self
.
_update_upgraded_room_pls
(
requester
,
old_room_id
,
new_room_id
,
old_room_state
requester
,
old_room_id
,
new_room_id
,
old_room_state
,
)
return
new_room_id
@defer.inlineCallbacks
def
_update_upgraded_room_pls
(
self
,
requester
,
old_room_id
,
new_room_id
,
old_room_state
self
,
requester
,
old_room_id
,
new_room_id
,
old_room_state
,
):
"""
Send updated power levels in both rooms after an upgrade
Args:
requester (synapse.types.Requester): the user requesting the upgrade
old_room_id (
unicode
): the id of the room to be replaced
new_room_id (
unicode
): the id of the replacement room
old_room_id (
str
): the id of the room to be replaced
new_room_id (
str
): the id of the replacement room
old_room_state (dict[tuple[str, str], str]): the state map for the old room
Returns:
...
...
@@ -298,7 +298,7 @@ class RoomCreationHandler(BaseHandler):
tombstone_event_id (unicode|str): the ID of the tombstone event in the old
room.
Returns:
Deferred
[None]
Deferred
"""
user_id
=
requester
.
user
.
to_string
()
...
...
@@ -333,6 +333,7 @@ class RoomCreationHandler(BaseHandler):
(
EventTypes
.
Encryption
,
""
),
(
EventTypes
.
ServerACL
,
""
),
(
EventTypes
.
RelatedGroups
,
""
),
(
EventTypes
.
PowerLevels
,
""
),
)
old_room_state_ids
=
yield
self
.
store
.
get_filtered_current_state_ids
(
...
...
@@ -346,6 +347,31 @@ class RoomCreationHandler(BaseHandler):
if
old_event
:
initial_state
[
k
]
=
old_event
.
content
# Resolve the minimum power level required to send any state event
# We will give the upgrading user this power level temporarily (if necessary) such that
# they are able to copy all of the state events over, then revert them back to their
# original power level afterwards in _update_upgraded_room_pls
# Copy over user power levels now as this will not be possible with >100PL users once
# the room has been created
power_levels
=
initial_state
[(
EventTypes
.
PowerLevels
,
""
)]
# Calculate the minimum power level needed to clone the room
event_power_levels
=
power_levels
.
get
(
"
events
"
,
{})
state_default
=
power_levels
.
get
(
"
state_default
"
,
0
)
ban
=
power_levels
.
get
(
"
ban
"
)
needed_power_level
=
max
(
state_default
,
ban
,
max
(
event_power_levels
.
values
()))
# Raise the requester's power level in the new room if necessary
current_power_level
=
power_levels
[
"
users
"
][
requester
.
user
.
to_string
()]
if
current_power_level
<
needed_power_level
:
# Assign this power level to the requester
power_levels
[
"
users
"
][
requester
.
user
.
to_string
()]
=
needed_power_level
# Set the power levels to the modified state
initial_state
[(
EventTypes
.
PowerLevels
,
""
)]
=
power_levels
yield
self
.
_send_events_for_new_room
(
requester
,
new_room_id
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment