diff --git a/config.go b/config.go index d32035b..300fc86 100644 --- a/config.go +++ b/config.go @@ -202,8 +202,8 @@ func NewConfig(configPathOrContents any, dataPath string, logs LoggerSet) (*Conf config.Section("email").Key("no_username").SetValue(strconv.FormatBool(config.Section("email").Key("no_username").MustBool(false))) // FIXME: Remove all these, eventually - // config.MustSetValue("password_resets", "email_html", "jfa-go:"+"email.html") - // config.MustSetValue("password_resets", "email_text", "jfa-go:"+"email.txt") + // config.MustSetValue("password_resets", "email_html", "jfa-go:"+"password-reset.html") + // config.MustSetValue("password_resets", "email_text", "jfa-go:"+"password-reset.txt") // config.MustSetValue("invite_emails", "email_html", "jfa-go:"+"invite-email.html") // config.MustSetValue("invite_emails", "email_text", "jfa-go:"+"invite-email.txt") diff --git a/migrations.go b/migrations.go index d700474..6e883b0 100644 --- a/migrations.go +++ b/migrations.go @@ -23,6 +23,7 @@ func runMigrations(app *appContext) { migrateToBadger(app) intialiseCustomContent(app) migrateJellyseerrImportDaemon(app) + migratePWREmailPath(app) } // Migrate pre-0.2.0 user templates to profiles @@ -514,3 +515,23 @@ func migrateJellyseerrImportDaemon(app *appContext) { app.storage.db.Upsert("jellyseerr_inital_sync_status", JellyseerrInitialSyncStatus{false}) } } + +// Migrate previous filepath to the password reset email (email.html/txt) to new one. +func migratePWREmailPath(app *appContext) { + if app.config.Section("password_resets").Key("email_html").String() != "jfa-go:email.html" && app.config.Section("password_resets").Key("email_text").String() != "jfa-go:email.txt" { + return + } + tempConfig, _ := ini.ShadowLoad(app.configPath) + if app.config.Section("password_resets").Key("email_html").String() == "jfa-go:email.html" { + tempConfig.Section("password_resets").Key("email_html").SetValue("") + } + if app.config.Section("password_resets").Key("email_text").String() == "jfa-go:email.txt" { + tempConfig.Section("password_resets").Key("email_text").SetValue("") + } + err := tempConfig.SaveTo(app.configPath) + if err != nil { + app.err.Fatalf("Failed to save config: %v", err) + return + } + app.ReloadConfig() +}