diff --git a/irc/accounts.go b/irc/accounts.go index 8f8e8b45..97237523 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -2294,7 +2294,6 @@ type ReplayJoinsSetting uint const ( ReplayJoinsCommandsOnly = iota // replay in HISTORY or CHATHISTORY output ReplayJoinsAlways // replay in HISTORY, CHATHISTORY, or autoreplay - ReplayJoinsNever // never replay ) func replayJoinsSettingFromString(str string) (result ReplayJoinsSetting, err error) { @@ -2303,8 +2302,6 @@ func replayJoinsSettingFromString(str string) (result ReplayJoinsSetting, err er result = ReplayJoinsCommandsOnly case "always": result = ReplayJoinsAlways - case "never": - result = ReplayJoinsNever default: err = errInvalidParams } diff --git a/irc/database.go b/irc/database.go index b4b417f4..bfca9d07 100644 --- a/irc/database.go +++ b/irc/database.go @@ -24,7 +24,7 @@ const ( // 'version' of the database schema keySchemaVersion = "db.version" // latest schema of the db - latestDbSchema = 21 + latestDbSchema = 22 keyCloakSecret = "crypto.cloak_secret" ) @@ -1059,6 +1059,56 @@ func schemaChangeV20To21(config *Config, tx *buntdb.Tx) error { return nil } +// #1676: we used to have ReplayJoinsNever, now it's desupported +func schemaChangeV21To22(config *Config, tx *buntdb.Tx) error { + type accountSettingsv22 struct { + AutoreplayLines *int + NickEnforcement NickEnforcementMethod + AllowBouncer MulticlientAllowedSetting + ReplayJoins ReplayJoinsSetting + AlwaysOn PersistentStatus + AutoreplayMissed bool + DMHistory HistoryStatus + AutoAway PersistentStatus + Email string + } + + var accounts []string + var serializedSettings []string + settingsPrefix := "account.settings " + tx.AscendGreaterOrEqual("", settingsPrefix, func(key, value string) bool { + if !strings.HasPrefix(key, settingsPrefix) { + return false + } + account := strings.TrimPrefix(key, settingsPrefix) + if _, err := tx.Get("account.verified " + account); err != nil { + return true + } + var settings accountSettingsv22 + err := json.Unmarshal([]byte(value), &settings) + if err != nil { + log.Printf("error (v21-22) processing settings for %s: %v\n", account, err) + return true + } + // if necessary, change ReplayJoinsNever (2) to ReplayJoinsCommandsOnly (0) + if settings.ReplayJoins == ReplayJoinsSetting(2) { + settings.ReplayJoins = ReplayJoinsSetting(0) + if b, err := json.Marshal(settings); err == nil { + accounts = append(accounts, account) + serializedSettings = append(serializedSettings, string(b)) + } else { + log.Printf("error (v21-22) processing settings for %s: %v\n", account, err) + } + } + return true + }) + + for i, account := range accounts { + tx.Set(settingsPrefix+account, serializedSettings[i], nil) + } + return nil +} + func getSchemaChange(initialVersion int) (result SchemaChange, ok bool) { for _, change := range allChanges { if initialVersion == change.InitialVersion { @@ -1169,4 +1219,9 @@ var allChanges = []SchemaChange{ TargetVersion: 21, Changer: schemaChangeV20To21, }, + { + InitialVersion: 21, + TargetVersion: 22, + Changer: schemaChangeV21To22, + }, } diff --git a/irc/nickserv.go b/irc/nickserv.go index 3658c8fb..8166fee8 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -284,8 +284,8 @@ default.`, `$bREPLAY-JOINS$b 'replay-joins' controls whether replayed channel history will include lines for join and part. This provides more information about the context of -messages, but may be spammy. Your options are 'always', 'never', and the default -of 'commands-only' (the messages will be replayed in /HISTORY output, but not +messages, but may be spammy. Your options are 'always' and the default of +'commands-only' (the messages will be replayed in CHATHISTORY output, but not during autoreplay).`, `$bALWAYS-ON$b 'always-on' controls whether your nickname/identity will remain active @@ -440,8 +440,6 @@ func displaySetting(service *ircService, settingName string, settings AccountSet service.Notice(rb, client.t("You will see JOINs and PARTs in /HISTORY output, but not in autoreplay")) case ReplayJoinsAlways: service.Notice(rb, client.t("You will see JOINs and PARTs in /HISTORY output and in autoreplay")) - case ReplayJoinsNever: - service.Notice(rb, client.t("You will not see JOINs and PARTs in /HISTORY output or in autoreplay")) } case "multiclient": if !config.Accounts.Multiclient.Enabled {