email: add migration for pwr email file rename

sorry this was broken for a while for old users.
This commit is contained in:
Harvey Tindall
2025-12-02 00:40:48 +00:00
parent 50455b828d
commit f74e85662a
2 changed files with 23 additions and 2 deletions

View File

@@ -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")

View File

@@ -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()
}