2020-08-10 15:18:04 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
type RoomServer struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2020-08-13 13:16:37 +02:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api"`
|
2020-08-10 15:18:04 +02:00
|
|
|
|
|
|
|
Database DatabaseOptions `yaml:"database"`
|
|
|
|
}
|
|
|
|
|
2021-11-24 12:57:39 +01:00
|
|
|
func (c *RoomServer) Defaults(generate bool) {
|
2020-08-13 13:16:37 +02:00
|
|
|
c.InternalAPI.Listen = "http://localhost:7770"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7770"
|
2021-03-08 14:18:29 +01:00
|
|
|
c.Database.Defaults(10)
|
2021-11-24 12:57:39 +01:00
|
|
|
if generate {
|
|
|
|
c.Database.ConnectionString = "file:roomserver.db"
|
|
|
|
}
|
2020-08-10 15:18:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *RoomServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
2022-05-03 17:35:06 +02:00
|
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
|
|
checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString))
|
|
|
|
}
|
2022-05-13 09:33:55 +02:00
|
|
|
if isMonolith { // polylith required configs below
|
|
|
|
return
|
|
|
|
}
|
|
|
|
checkURL(configErrs, "room_server.internal_api.listen", string(c.InternalAPI.Listen))
|
|
|
|
checkURL(configErrs, "room_server.internal_ap.connect", string(c.InternalAPI.Connect))
|
2020-08-10 15:18:04 +02:00
|
|
|
}
|