diff options
author | Sam Wedgwood <28223854+swedgwood@users.noreply.github.com> | 2023-08-08 14:20:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-08 14:20:05 +0100 |
commit | 35804f8493a7a51542b27ff98bc60814685d5020 (patch) | |
tree | 0138df2ced6da0f8d03a51d38ace5a3651f68cd2 /setup/config | |
parent | 294eff8a7f42f11b3559ca941468c766358fcae1 (diff) |
Add config key for default room version (#3171)
This PR adds a config key `room_server.default_config_key` to set the
default room version for the room server.
Signed-off-by: `Sam Wedgwood <sam@wedgwood.dev>`
Diffstat (limited to 'setup/config')
-rw-r--r-- | setup/config/config_roomserver.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/setup/config/config_roomserver.go b/setup/config/config_roomserver.go index 319c2419..06e7757f 100644 --- a/setup/config/config_roomserver.go +++ b/setup/config/config_roomserver.go @@ -1,12 +1,22 @@ package config +import ( + "fmt" + + "github.com/matrix-org/gomatrixserverlib" + log "github.com/sirupsen/logrus" +) + type RoomServer struct { Matrix *Global `yaml:"-"` + DefaultRoomVersion gomatrixserverlib.RoomVersion `yaml:"default_room_version,omitempty"` + Database DatabaseOptions `yaml:"database,omitempty"` } func (c *RoomServer) Defaults(opts DefaultOpts) { + c.DefaultRoomVersion = gomatrixserverlib.RoomVersionV10 if opts.Generate { if !opts.SingleDatabase { c.Database.ConnectionString = "file:roomserver.db" @@ -18,4 +28,10 @@ func (c *RoomServer) Verify(configErrs *ConfigErrors) { if c.Matrix.DatabaseOptions.ConnectionString == "" { checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString)) } + + if !gomatrixserverlib.KnownRoomVersion(c.DefaultRoomVersion) { + configErrs.Add(fmt.Sprintf("invalid value for config key 'room_server.default_room_version': unsupported room version: %q", c.DefaultRoomVersion)) + } else if !gomatrixserverlib.StableRoomVersion(c.DefaultRoomVersion) { + log.Warnf("WARNING: Provided default room version %q is unstable", c.DefaultRoomVersion) + } } |