invites: allow notification by discord/telegram/matrix

also added migration as this required changing the indexing of notify
preferences from email addresses to Jellyfin IDs.
This commit is contained in:
Harvey Tindall
2021-11-17 16:16:19 +00:00
parent 3730775018
commit e7ca335d83
3 changed files with 77 additions and 17 deletions
+35
View File
@@ -13,6 +13,7 @@ func runMigrations(app *appContext) {
migrateProfiles(app)
migrateBootstrap(app)
migrateEmailStorage(app)
migrateNotificationMethods(app)
// migrateHyphens(app)
}
@@ -123,6 +124,40 @@ func migrateEmailStorage(app *appContext) error {
return nil
}
// Pre-0.3.10, Admin notifications for invites were indexed by and only sent to email addresses. Now, when Jellyfin Login is enabled, They are indexed by the admin's Jellyfin ID, and send by any method enabled for them. This migrates storage to that format.
func migrateNotificationMethods(app *appContext) error {
if !app.config.Section("ui").Key("jellyfin_login").MustBool(false) {
return nil
}
changes := false
for code, invite := range app.storage.invites {
if invite.Notify == nil {
continue
}
for address, notifyPrefs := range invite.Notify {
if !strings.Contains(address, "@") {
continue
}
for id, email := range app.storage.emails {
if email.Addr == address {
invite.Notify[id] = notifyPrefs
delete(invite.Notify, address)
changes = true
break
}
}
}
if changes {
app.storage.invites[code] = invite
}
}
if changes {
app.info.Printf("Migrated to modified invite storage format.")
return app.storage.storeInvites()
}
return nil
}
// Migrate between hyphenated & non-hyphenated user IDs. Doesn't seem to happen anymore, so disabled.
// func migrateHyphens(app *appContext) {
// checkVersion := func(version string) int {