mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
accounts: invalidate user cache in more/all places
using app.userSummary as a source of relevant storage places and things to look for.
This commit is contained in:
@@ -104,6 +104,7 @@ func (app *appContext) deleteExpiredInvite(data Invite) {
|
||||
if ok {
|
||||
user.ReferralTemplateKey = ""
|
||||
app.storage.SetEmailsKey(data.ReferrerJellyfinID, user)
|
||||
app.InvalidateWebUserCache()
|
||||
}
|
||||
}
|
||||
wait := app.sendAdminExpiryNotification(data)
|
||||
|
||||
@@ -271,6 +271,7 @@ func (app *appContext) TelegramAddUser(gc *gin.Context) {
|
||||
}
|
||||
|
||||
linkExistingOmbiDiscordTelegram(app)
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -336,6 +337,7 @@ func (app *appContext) setContactMethods(req SetContactMethodsDTO, gc *gin.Conte
|
||||
app.err.Printf(lm.FailedSyncContactMethods, lm.Jellyseerr, err)
|
||||
}
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -564,6 +566,7 @@ func (app *appContext) MatrixConnect(gc *gin.Context) {
|
||||
Lang: "en-us",
|
||||
Contact: true,
|
||||
})
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -635,6 +638,7 @@ func (app *appContext) DiscordConnect(gc *gin.Context) {
|
||||
}, gc, false)
|
||||
|
||||
linkExistingOmbiDiscordTelegram(app)
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -672,6 +676,7 @@ func (app *appContext) UnlinkDiscord(gc *gin.Context) {
|
||||
Time: time.Now(),
|
||||
}, gc, false)
|
||||
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -708,6 +713,7 @@ func (app *appContext) UnlinkTelegram(gc *gin.Context) {
|
||||
Time: time.Now(),
|
||||
}, gc, false)
|
||||
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -737,5 +743,6 @@ func (app *appContext) UnlinkMatrix(gc *gin.Context) {
|
||||
Time: time.Now(),
|
||||
}, gc, false)
|
||||
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -796,6 +796,7 @@ func (app *appContext) GetMyReferral(gc *gin.Context) {
|
||||
inv.ValidTill = inv.Created.Add(REFERRAL_EXPIRY_DAYS * 24 * time.Hour)
|
||||
app.storage.SetInvitesKey(inv.Code, inv)
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
gc.JSON(200, GetMyReferralRespDTO{
|
||||
Code: inv.Code,
|
||||
RemainingUses: inv.RemainingUses,
|
||||
|
||||
@@ -625,6 +625,7 @@ func (app *appContext) EnableReferralForUsers(gc *gin.Context) {
|
||||
inv.UseReferralExpiry = useExpiry
|
||||
app.storage.SetInvitesKey(inv.Code, inv)
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
}
|
||||
|
||||
// @Summary Disable referrals for the given user(s).
|
||||
@@ -648,6 +649,7 @@ func (app *appContext) DisableReferralForUsers(gc *gin.Context) {
|
||||
user.ReferralTemplateKey = ""
|
||||
app.storage.SetEmailsKey(u, user)
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(200, true, gc)
|
||||
}
|
||||
|
||||
@@ -848,6 +850,8 @@ func (app *appContext) AdminPasswordReset(gc *gin.Context) {
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
// userSummary generates a respUser for to be displayed to the user, or sorted/filtered.
|
||||
// also, consider it a source of which data fields/struct modifications need to trigger a cache invalidation.
|
||||
func (app *appContext) userSummary(jfUser mediabrowser.User) respUser {
|
||||
adminOnly := app.config.Section("ui").Key("admin_only").MustBool(true)
|
||||
allowAll := app.config.Section("ui").Key("allow_all").MustBool(false)
|
||||
@@ -1016,6 +1020,7 @@ func (app *appContext) SetAccountsAdmin(gc *gin.Context) {
|
||||
app.info.Printf(lm.UserAdminAdjusted, id, admin)
|
||||
}
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
@@ -1048,6 +1053,7 @@ func (app *appContext) ModifyLabels(gc *gin.Context) {
|
||||
app.storage.SetEmailsKey(id, emailStore)
|
||||
}
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
respondBool(204, true, gc)
|
||||
}
|
||||
|
||||
@@ -1087,6 +1093,7 @@ func (app *appContext) modifyEmail(jfID string, addr string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
app.InvalidateWebUserCache()
|
||||
}
|
||||
|
||||
// @Summary Modify user's email addresses.
|
||||
|
||||
@@ -131,6 +131,7 @@ func (app *appContext) checkUsers(remindBeforeExpiry *DayTimerSet) {
|
||||
activity.Type = ActivityDeletion
|
||||
// Store the user name, since there's no longer a user ID to reference back to
|
||||
activity.Value = user.Name
|
||||
app.InvalidateUserCaches()
|
||||
} else {
|
||||
app.info.Printf(lm.DisableExpiredUser, user.Name)
|
||||
// Admins can't be disabled
|
||||
@@ -138,6 +139,7 @@ func (app *appContext) checkUsers(remindBeforeExpiry *DayTimerSet) {
|
||||
user.Policy.IsAdministrator = false
|
||||
err, _, _ = app.SetUserDisabled(user, true)
|
||||
activity.Type = ActivityDisabled
|
||||
app.InvalidateUserCaches()
|
||||
}
|
||||
if err != nil {
|
||||
app.err.Printf(lm.FailedDeleteOrDisableExpiredUser, user.ID, err)
|
||||
|
||||
Reference in New Issue
Block a user