2022-11-13 07:26:55 +03:00
|
|
|
package admin
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/owncast/owncast/core/data"
|
2024-07-02 08:17:10 +03:00
|
|
|
"github.com/owncast/owncast/webserver/handlers/generated"
|
2024-07-02 07:44:37 +03:00
|
|
|
webutils "github.com/owncast/owncast/webserver/utils"
|
2022-11-13 07:26:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// SetCustomColorVariableValues sets the custom color variables.
|
|
|
|
func SetCustomColorVariableValues(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if !requirePOST(w, r) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
decoder := json.NewDecoder(r.Body)
|
2024-07-02 08:17:10 +03:00
|
|
|
var values generated.SetCustomColorVariableValuesJSONBody
|
2022-11-13 07:26:55 +03:00
|
|
|
|
|
|
|
if err := decoder.Decode(&values); err != nil {
|
2024-07-02 07:44:37 +03:00
|
|
|
webutils.WriteSimpleResponse(w, false, "unable to update appearance variable values")
|
2022-11-13 07:26:55 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-07-02 08:17:10 +03:00
|
|
|
if err := data.SetCustomColorVariableValues(*values.Value); err != nil {
|
2024-07-02 07:44:37 +03:00
|
|
|
webutils.WriteSimpleResponse(w, false, err.Error())
|
2022-11-13 07:26:55 +03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-07-02 07:44:37 +03:00
|
|
|
webutils.WriteSimpleResponse(w, true, "custom appearance variables updated")
|
2022-11-13 07:26:55 +03:00
|
|
|
}
|