mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
Add comment to restrictOldRoomPowerLevels
This commit is contained in:
parent
e211836f5a
commit
95bb7a51c1
|
|
@ -143,14 +143,15 @@ func (r *Upgrader) getRoomPowerLevels(ctx context.Context, roomID string) (*goma
|
|||
}
|
||||
|
||||
func (r *Upgrader) restrictOldRoomPowerLevels(ctx context.Context, evTime time.Time, userID, roomID string) *api.PerformError {
|
||||
powerLevelContent, pErr := r.getRoomPowerLevels(ctx, roomID)
|
||||
restrictedPowerLevelContent, pErr := r.getRoomPowerLevels(ctx, roomID)
|
||||
if pErr != nil {
|
||||
return pErr
|
||||
}
|
||||
|
||||
restrictedPowerLevelContent := &gomatrixserverlib.PowerLevelContent{}
|
||||
*restrictedPowerLevelContent = *powerLevelContent
|
||||
|
||||
// From: https://spec.matrix.org/v1.2/client-server-api/#server-behaviour-16
|
||||
// If possible, the power levels in the old room should also be modified to
|
||||
// prevent sending of events and inviting new users. For example, setting
|
||||
// events_default and invite to the greater of 50 and users_default + 1.
|
||||
restrictedDefaultPowerLevel := int64(50)
|
||||
if restrictedPowerLevelContent.UsersDefault+1 > restrictedDefaultPowerLevel {
|
||||
restrictedDefaultPowerLevel = restrictedPowerLevelContent.UsersDefault + 1
|
||||
|
|
@ -160,6 +161,7 @@ func (r *Upgrader) restrictOldRoomPowerLevels(ctx context.Context, evTime time.T
|
|||
|
||||
restrictedPowerLevelsHeadered, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, fledglingEvent{
|
||||
Type: gomatrixserverlib.MRoomPowerLevels,
|
||||
StateKey: "",
|
||||
Content: restrictedPowerLevelContent,
|
||||
})
|
||||
if resErr != nil {
|
||||
|
|
@ -242,12 +244,12 @@ func (r *Upgrader) publishIfOldRoomWasPublic(ctx context.Context, roomID, newRoo
|
|||
|
||||
// if the old room is published (was public), publish the new room
|
||||
if len(pubQueryRes.RoomIDs) == 1 {
|
||||
publishNewRoom(ctx, r.URSAPI, roomID, newRoomID)
|
||||
publishNewRoomAndUnpublishOldRoom(ctx, r.URSAPI, roomID, newRoomID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func publishNewRoom(
|
||||
func publishNewRoomAndUnpublishOldRoom(
|
||||
ctx context.Context,
|
||||
URSAPI api.RoomserverInternalAPI,
|
||||
oldRoomID, newRoomID string,
|
||||
|
|
|
|||
|
|
@ -680,6 +680,3 @@ remote user has push rules copied to upgraded room
|
|||
Cannot send tombstone event that points to the same room
|
||||
Room summary counts change when membership changes
|
||||
/upgrade copies >100 power levels to the new room
|
||||
/upgrade moves remote aliases to the new room
|
||||
/upgrade preserves direct room state
|
||||
Local and remote users' homeservers remove a room from their public directory on upgrade
|
||||
|
|
|
|||
Loading…
Reference in a new issue