remove migrations

This commit is contained in:
Aine
2022-08-31 10:33:13 +03:00
parent 67f504f888
commit 104e948b9c
10 changed files with 10 additions and 54 deletions

View File

@@ -40,25 +40,18 @@ func (s botSettings) Users() []string {
return []string{value}
}
func (b *Bot) initBotUsers(envUsers []string) ([]string, error) {
func (b *Bot) initBotUsers() ([]string, error) {
config := b.getBotSettings()
cfgUsers := config.Users()
if len(cfgUsers) > 0 {
// already migrated
return cfgUsers, nil
}
if len(envUsers) == 0 {
_, homeserver, err := b.lp.GetClient().UserID.Parse()
if err != nil {
return nil, err
}
config.Set(botOptionUsers, "@*:"+homeserver)
} else {
// Initialize from environment variable
// TODO: remove this migration later and always initialize to `"@*:"+homeserver`
config.Set(botOptionUsers, strings.Join(envUsers, " "))
}
_, homeserver, err := b.lp.GetClient().UserID.Parse()
if err != nil {
return nil, err
}
config.Set(botOptionUsers, "@*:"+homeserver)
return config.Users(), b.setBotSettings(config)
}