Changeset 0.13.1 (#65)
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/models"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/providers"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/store"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/tools/search"
|
||||
)
|
||||
|
||||
type AdminHandler struct {
|
||||
@@ -260,9 +261,32 @@ func (h *AdminHandler) UpdateGlobalSetting(c *gin.Context) {
|
||||
}
|
||||
|
||||
h.auditLog(c, "settings.update", "global_settings", key, nil)
|
||||
|
||||
// Live-apply hooks for settings that have runtime effects
|
||||
if key == "search_config" {
|
||||
applySearchConfig(jsonVal)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{"message": "setting updated"})
|
||||
}
|
||||
|
||||
// applySearchConfig updates the active search provider at runtime.
|
||||
func applySearchConfig(raw models.JSONMap) {
|
||||
b, err := json.Marshal(raw)
|
||||
if err != nil {
|
||||
log.Printf("⚠️ Failed to marshal search config: %v", err)
|
||||
return
|
||||
}
|
||||
var cfg search.Config
|
||||
if err := json.Unmarshal(b, &cfg); err != nil {
|
||||
log.Printf("⚠️ Failed to parse search config: %v", err)
|
||||
return
|
||||
}
|
||||
if err := search.ApplyConfig(cfg); err != nil {
|
||||
log.Printf("⚠️ Failed to apply search config: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *AdminHandler) PublicSettings(c *gin.Context) {
|
||||
// Banner config, branding, etc. — safe subset for non-admin users
|
||||
banner, _ := h.stores.GlobalConfig.Get(c.Request.Context(), "banner")
|
||||
|
||||
Reference in New Issue
Block a user