owncast/webserver/handlers/admin/appearance.go
Gabe Kangas 0b5d7c8a4d
Config repository (#3988)
* WIP

* fix(test): fix ap test failing

* fix: fix unkeyed fields being used

* chore(tests): clean up browser tests by splitting out federation UI tests
2024-11-15 19:20:58 -08:00

33 lines
932 B
Go

package admin
import (
"encoding/json"
"net/http"
"github.com/owncast/owncast/persistence/configrepository"
"github.com/owncast/owncast/webserver/handlers/generated"
webutils "github.com/owncast/owncast/webserver/utils"
)
// SetCustomColorVariableValues sets the custom color variables.
func SetCustomColorVariableValues(w http.ResponseWriter, r *http.Request) {
if !requirePOST(w, r) {
return
}
decoder := json.NewDecoder(r.Body)
var values generated.SetCustomColorVariableValuesJSONBody
if err := decoder.Decode(&values); err != nil {
webutils.WriteSimpleResponse(w, false, "unable to update appearance variable values")
return
}
configRepository := configrepository.Get()
if err := configRepository.SetCustomColorVariableValues(*values.Value); err != nil {
webutils.WriteSimpleResponse(w, false, err.Error())
return
}
webutils.WriteSimpleResponse(w, true, "custom appearance variables updated")
}