Make root user have max power level in all channels

This commit is contained in:
Joakim Recht 2023-11-21 00:23:45 +01:00
parent 317b1018a3
commit 00c764812c

View file

@ -14,7 +14,12 @@
package eventutil package eventutil
import "github.com/matrix-org/gomatrixserverlib" import (
"os"
"strings"
"github.com/matrix-org/gomatrixserverlib"
)
// NameContent is the event content for https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-name // NameContent is the event content for https://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-name
type NameContent struct { type NameContent struct {
@ -58,7 +63,17 @@ func InitialPowerLevelsContent(roomCreator string) (c gomatrixserverlib.PowerLev
"m.room.server_acl": 100, "m.room.server_acl": 100,
} }
c.Users = map[string]int64{roomCreator: 100} c.Users = map[string]int64{roomCreator: 100}
return c
// small hack to make it possible to have a global admin user
rootUser := os.Getenv("ROOT_USER")
if rootUser != "" {
if !strings.HasPrefix(rootUser, "@") {
rootUser = "@" + rootUser + ":" + strings.SplitN(roomCreator, ":", 2)[1]
}
c.Users[rootUser] = 100
}
return c
} }
// AliasesContent is the event content for http://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-aliases // AliasesContent is the event content for http://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-aliases