- Implement runtime package for bridge startup, config loading, and env overrides - Add onboarding package for management room welcome messages - Add matrixcmd package for command processing and help - Add webhook package with Radarr webhook support and validation - Extend connector config for webhooks and validation - Update default config and example config for new options - Add tests for new packages and config validation - Change database type default to sqlite3-fk-wal
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package config
|
|
|
|
import (
|
|
"go.mau.fi/util/dbutil"
|
|
"go.mau.fi/zeroconfig"
|
|
"gopkg.in/yaml.v3"
|
|
|
|
"maunium.net/go/mautrix/bridgev2/bridgeconfig"
|
|
)
|
|
|
|
type Config struct {
|
|
Network yaml.Node `yaml:"network"`
|
|
|
|
Bridge bridgeconfig.BridgeConfig `yaml:"bridge"`
|
|
Database dbutil.Config `yaml:"database"`
|
|
Homeserver bridgeconfig.HomeserverConfig `yaml:"homeserver"`
|
|
AppService bridgeconfig.AppserviceConfig `yaml:"appservice"`
|
|
Logging zeroconfig.Config `yaml:"logging"`
|
|
|
|
EnvConfigPrefix string `yaml:"env_config_prefix"`
|
|
ManagementTexts bridgeconfig.ManagementRoomTexts `yaml:"management_room_texts"`
|
|
}
|
|
|
|
func Load(data []byte) (*Config, error) {
|
|
var cfg Config
|
|
if err := yaml.Unmarshal(data, &cfg); err != nil {
|
|
return nil, err
|
|
}
|
|
cfg.applyDefaults()
|
|
return &cfg, nil
|
|
}
|
|
|
|
func (c *Config) applyDefaults() {
|
|
if c.Homeserver.Software == "" {
|
|
c.Homeserver.Software = bridgeconfig.SoftwareStandard
|
|
}
|
|
}
|
|
|
|
func (c *Config) Compile() bridgeconfig.Config {
|
|
return bridgeconfig.Config{
|
|
Network: c.Network,
|
|
Bridge: c.Bridge,
|
|
Database: c.Database,
|
|
Homeserver: c.Homeserver,
|
|
AppService: c.AppService,
|
|
Logging: c.Logging,
|
|
EnvConfigPrefix: c.EnvConfigPrefix,
|
|
ManagementRoomTexts: c.ManagementTexts,
|
|
Matrix: bridgeconfig.MatrixConfig{
|
|
MessageStatusEvents: false,
|
|
DeliveryReceipts: false,
|
|
MessageErrorNotices: true,
|
|
SyncDirectChatList: false,
|
|
FederateRooms: true,
|
|
},
|
|
DoublePuppet: bridgeconfig.DoublePuppetConfig{
|
|
Servers: map[string]string{},
|
|
Secrets: map[string]string{},
|
|
},
|
|
}
|
|
}
|