Add custom offline message+api. Part of #1901

This commit is contained in:
Gabe Kangas
2022-08-09 22:09:43 -07:00
parent 2c1624127a
commit 681067ab93
9 changed files with 73 additions and 2 deletions

View File

@@ -141,6 +141,25 @@ func SetServerSummary(w http.ResponseWriter, r *http.Request) {
controllers.WriteSimpleResponse(w, true, "changed")
}
// SetCustomOfflineMessage will set a message to display when the server is offline.
func SetCustomOfflineMessage(w http.ResponseWriter, r *http.Request) {
if !requirePOST(w, r) {
return
}
configValue, success := getValueFromRequest(w, r)
if !success {
return
}
if err := data.SetCustomOfflineMessage(strings.TrimSpace(configValue.Value.(string))); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
controllers.WriteSimpleResponse(w, true, "changed")
}
// SetServerWelcomeMessage will handle the web config request to set the welcome message text.
func SetServerWelcomeMessage(w http.ResponseWriter, r *http.Request) {
if !requirePOST(w, r) {

View File

@@ -41,6 +41,7 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
ExtraPageContent: data.GetExtraPageBodyContent(),
StreamTitle: data.GetStreamTitle(),
WelcomeMessage: data.GetServerWelcomeMessage(),
OfflineMessage: data.GetCustomOfflineMessage(),
Logo: data.GetLogoPath(),
SocialHandles: data.GetSocialHandles(),
NSFW: data.GetNSFW(),
@@ -126,6 +127,7 @@ type webConfigResponse struct {
Name string `json:"name"`
Summary string `json:"summary"`
WelcomeMessage string `json:"welcomeMessage"`
OfflineMessage string `json:"offlineMessage"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Version string `json:"version"`