Feat settings cascade (#3)
Some checks failed
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 5s
CI/CD / test-go-pg (push) Failing after 2m24s
CI/CD / test-sqlite (push) Successful in 2m48s
CI/CD / build-and-deploy (push) Has been skipped

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
2026-03-26 18:03:44 +00:00
committed by xcaliber
parent a830ae3684
commit a36be83aaf
15 changed files with 690 additions and 49 deletions

View File

@@ -7,6 +7,8 @@ import (
"github.com/gin-gonic/gin"
"strings"
"switchboard-core/database"
"switchboard-core/models"
"switchboard-core/store"
@@ -91,7 +93,27 @@ func (h *ExtensionHandler) UpdateUserExtensionSettings(c *gin.Context) {
settings := json.RawMessage("{}")
if body.Settings != nil {
settings = body.Settings
// v0.2.0: enforce user_overridable — strip locked keys before saving
schema := store.ParseSettingsSchema(pkg.Manifest)
if len(schema) > 0 {
var incoming map[string]any
if json.Unmarshal(body.Settings, &incoming) == nil && len(incoming) > 0 {
filtered, rejected := store.FilterOverridableKeys(incoming, schema)
if len(filtered) == 0 && len(rejected) > 0 {
c.JSON(400, gin.H{"error": "these settings cannot be overridden: " + strings.Join(rejected, ", ")})
return
}
if b, err := json.Marshal(filtered); err == nil {
settings = json.RawMessage(b)
} else {
settings = body.Settings
}
} else {
settings = body.Settings
}
} else {
settings = body.Settings
}
}
pus := &store.PackageUserSettings{