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