Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

949 B
Raw Blame
package admin

import (
	"encoding/json"
	"net/http"

	"github.com/owncast/owncast/webserver/handlers/generated"
	webutils "github.com/owncast/owncast/webserver/utils"
)

// SetCustomColorVariableValues sets the custom color variables.
func (a *Admin) 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
	}

	if values.Value == nil {
		webutils.WriteSimpleResponse(w, false, "value field is required")
		return
	}

	if err := a.configRepository.SetCustomColorVariableValues(*values.Value); err != nil {
		webutils.WriteSimpleResponse(w, false, err.Error())
		return
	}

	webutils.WriteSimpleResponse(w, true, "custom appearance variables updated")
}