2020-08-10 14:18:04 +01:00
|
|
|
package config
|
|
|
|
|
2023-08-08 14:20:05 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2020-08-10 14:18:04 +01:00
|
|
|
type RoomServer struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2023-08-08 14:20:05 +01:00
|
|
|
DefaultRoomVersion gomatrixserverlib.RoomVersion `yaml:"default_room_version,omitempty"`
|
|
|
|
|
2022-09-01 14:15:41 +01:00
|
|
|
Database DatabaseOptions `yaml:"database,omitempty"`
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
2022-09-01 14:15:41 +01:00
|
|
|
func (c *RoomServer) Defaults(opts DefaultOpts) {
|
2023-08-08 14:20:05 +01:00
|
|
|
c.DefaultRoomVersion = gomatrixserverlib.RoomVersionV10
|
2022-09-01 14:15:41 +01:00
|
|
|
if opts.Generate {
|
2023-02-14 11:47:47 +00:00
|
|
|
if !opts.SingleDatabase {
|
2022-09-01 14:15:41 +01:00
|
|
|
c.Database.ConnectionString = "file:roomserver.db"
|
|
|
|
}
|
2021-11-24 11:57:39 +00:00
|
|
|
}
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|
|
|
|
|
2023-02-14 11:47:47 +00:00
|
|
|
func (c *RoomServer) Verify(configErrs *ConfigErrors) {
|
2022-09-01 14:15:41 +01:00
|
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
|
|
checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString))
|
|
|
|
}
|
2023-08-08 14:20:05 +01:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2020-08-10 14:18:04 +01:00
|
|
|
}
|