owncast/yp/api.go
gingervitis 01f16aeddf
Simplify Logo requirement from users. (#373)
* Simplify Logo requirement from users.
- Only require 1 logo file, instead of a `small` and `large` one.  Just require `logo`.
- Update frontend sso that primary header logo will ALWAYS be owncast logo.
- User's logo will remain in "user content" area.

* Commit updated API documentation

Co-authored-by: Owncast <owncast@owncast.online>
2020-11-17 15:12:54 -08:00

49 lines
1.6 KiB
Go

package yp
import (
"encoding/json"
"net/http"
"github.com/owncast/owncast/config"
"github.com/owncast/owncast/utils"
log "github.com/sirupsen/logrus"
)
type ypDetailsResponse struct {
Name string `json:"name"`
Description string `json:"description"`
Logo string `json:"logo"`
NSFW bool `json:"nsfw"`
Tags []string `json:"tags"`
Online bool `json:"online"`
ViewerCount int `json:"viewerCount"`
OverallMaxViewerCount int `json:"overallMaxViewerCount"`
SessionMaxViewerCount int `json:"sessionMaxViewerCount"`
LastConnectTime utils.NullTime `json:"lastConnectTime"`
}
// GetYPResponse gets the status of the server for YP purposes.
func GetYPResponse(w http.ResponseWriter, r *http.Request) {
status := getStatus()
response := ypDetailsResponse{
Name: config.Config.InstanceDetails.Name,
Description: config.Config.InstanceDetails.Summary,
Logo: config.Config.InstanceDetails.Logo,
NSFW: config.Config.InstanceDetails.NSFW,
Tags: config.Config.InstanceDetails.Tags,
Online: status.Online,
ViewerCount: status.ViewerCount,
OverallMaxViewerCount: status.OverallMaxViewerCount,
SessionMaxViewerCount: status.SessionMaxViewerCount,
LastConnectTime: status.LastConnectTime,
}
w.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(response)
if err != nil {
log.Errorln(err)
}
}