2020-08-10 08:18:04 -05:00
|
|
|
package config
|
|
|
|
|
|
|
|
type RoomServer struct {
|
|
|
|
Matrix *Global `yaml:"-"`
|
|
|
|
|
2022-09-01 08:15:41 -05:00
|
|
|
InternalAPI InternalAPIOptions `yaml:"internal_api,omitempty"`
|
2020-08-10 08:18:04 -05:00
|
|
|
|
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) {
|
|
|
|
if !opts.Monolithic {
|
|
|
|
c.InternalAPI.Listen = "http://localhost:7770"
|
|
|
|
c.InternalAPI.Connect = "http://localhost:7770"
|
|
|
|
c.Database.Defaults(20)
|
|
|
|
}
|
|
|
|
if opts.Generate {
|
|
|
|
if !opts.Monolithic {
|
|
|
|
c.Database.ConnectionString = "file:roomserver.db"
|
|
|
|
}
|
2021-11-24 05:57:39 -06:00
|
|
|
}
|
2020-08-10 08:18:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *RoomServer) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
2022-05-13 02:33:55 -05:00
|
|
|
if isMonolith { // polylith required configs below
|
|
|
|
return
|
|
|
|
}
|
2022-09-01 08:15:41 -05:00
|
|
|
if c.Matrix.DatabaseOptions.ConnectionString == "" {
|
|
|
|
checkNotEmpty(configErrs, "room_server.database.connection_string", string(c.Database.ConnectionString))
|
|
|
|
}
|
2022-05-13 02:33:55 -05:00
|
|
|
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 08:18:04 -05:00
|
|
|
}
|