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 {
|
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 {
|
if pErr != nil {
|
||||||
return pErr
|
return pErr
|
||||||
}
|
}
|
||||||
|
|
||||||
restrictedPowerLevelContent := &gomatrixserverlib.PowerLevelContent{}
|
// From: https://spec.matrix.org/v1.2/client-server-api/#server-behaviour-16
|
||||||
*restrictedPowerLevelContent = *powerLevelContent
|
// 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)
|
restrictedDefaultPowerLevel := int64(50)
|
||||||
if restrictedPowerLevelContent.UsersDefault+1 > restrictedDefaultPowerLevel {
|
if restrictedPowerLevelContent.UsersDefault+1 > restrictedDefaultPowerLevel {
|
||||||
restrictedDefaultPowerLevel = restrictedPowerLevelContent.UsersDefault + 1
|
restrictedDefaultPowerLevel = restrictedPowerLevelContent.UsersDefault + 1
|
||||||
|
|
@ -159,8 +160,9 @@ func (r *Upgrader) restrictOldRoomPowerLevels(ctx context.Context, evTime time.T
|
||||||
restrictedPowerLevelContent.Invite = restrictedDefaultPowerLevel
|
restrictedPowerLevelContent.Invite = restrictedDefaultPowerLevel
|
||||||
|
|
||||||
restrictedPowerLevelsHeadered, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, fledglingEvent{
|
restrictedPowerLevelsHeadered, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, fledglingEvent{
|
||||||
Type: gomatrixserverlib.MRoomPowerLevels,
|
Type: gomatrixserverlib.MRoomPowerLevels,
|
||||||
Content: restrictedPowerLevelContent,
|
StateKey: "",
|
||||||
|
Content: restrictedPowerLevelContent,
|
||||||
})
|
})
|
||||||
if resErr != nil {
|
if resErr != nil {
|
||||||
if resErr.Code == api.PerformErrorNotAllowed {
|
if resErr.Code == api.PerformErrorNotAllowed {
|
||||||
|
|
@ -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 the old room is published (was public), publish the new room
|
||||||
if len(pubQueryRes.RoomIDs) == 1 {
|
if len(pubQueryRes.RoomIDs) == 1 {
|
||||||
publishNewRoom(ctx, r.URSAPI, roomID, newRoomID)
|
publishNewRoomAndUnpublishOldRoom(ctx, r.URSAPI, roomID, newRoomID)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func publishNewRoom(
|
func publishNewRoomAndUnpublishOldRoom(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
URSAPI api.RoomserverInternalAPI,
|
URSAPI api.RoomserverInternalAPI,
|
||||||
oldRoomID, newRoomID string,
|
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
|
Cannot send tombstone event that points to the same room
|
||||||
Room summary counts change when membership changes
|
Room summary counts change when membership changes
|
||||||
/upgrade copies >100 power levels to the new room
|
/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