From d60dea61db0db184b246e068a08ef700b6819f4e Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Wed, 31 Jul 2024 15:54:05 +0100 Subject: [PATCH] accounts: make all components of profile application optional Basically, added the ability to -not- apply the profile's policy. --- api-users.go | 18 +++++++++++++----- html/admin.html | 4 ++++ lang/admin/en-us.json | 1 + models.go | 17 ++++++++++------- ts/modules/accounts.ts | 6 ++++-- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/api-users.go b/api-users.go index f16fe3d..ec41a94 100644 --- a/api-users.go +++ b/api-users.go @@ -1372,7 +1372,9 @@ func (app *appContext) ApplySettings(gc *gin.Context) { configuration = profile.Configuration displayprefs = profile.Displayprefs } - policy = profile.Policy + if req.Policy { + policy = profile.Policy + } if req.Ombi && app.config.Section("ombi").Key("enabled").MustBool(false) { if profile.Ombi != nil && len(profile.Ombi) != 0 { ombi = profile.Ombi @@ -1394,7 +1396,9 @@ func (app *appContext) ApplySettings(gc *gin.Context) { return } applyingFrom = "\"" + user.Name + "\"" - policy = user.Policy + if req.Policy { + policy = user.Policy + } if req.Homescreen { displayprefs, status, err = app.jf.GetDisplayPreferences(req.ID) if !(status == 200 || status == 204) || err != nil { @@ -1421,9 +1425,13 @@ func (app *appContext) ApplySettings(gc *gin.Context) { app.debug.Println("Adding delay between requests for large batch") } for _, id := range req.ApplyTo { - status, err := app.jf.SetPolicy(id, policy) - if !(status == 200 || status == 204) || err != nil { - errors["policy"][id] = fmt.Sprintf("%d: %s", status, err) + var status int + var err error + if req.Policy { + status, err = app.jf.SetPolicy(id, policy) + if !(status == 200 || status == 204) || err != nil { + errors["policy"][id] = fmt.Sprintf("%d: %s", status, err) + } } if shouldDelay { time.Sleep(250 * time.Millisecond) diff --git a/html/admin.html b/html/admin.html index 126f9e1..cd72885 100644 --- a/html/admin.html +++ b/html/admin.html @@ -101,6 +101,10 @@
+