Skip to content

Commit

Permalink
Add “services” and “metadata” to NodeInfo/2.0 (owncast#1922)
Browse files Browse the repository at this point in the history
* add services to nodeinfo/2.0

* add metadata to Nodeinfo/2.0
  • Loading branch information
MFTabriz authored May 24, 2022
1 parent afeef6f commit 10cdf3d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions activitypub/controllers/nodeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ func NodeInfoController(w http.ResponseWriter, r *http.Request) {

// NodeInfoV2Controller returns the V2 node info response.
func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {
type metadata struct {
ChatEnabled bool `json:"chat_enabled"`
}
type services struct {
Outbound []string `json:"outbound"`
Inbound []string `json:"inbound"`
}
type software struct {
Name string `json:"name"`
Version string `json:"version"`
Expand All @@ -74,10 +81,12 @@ func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {
}
type response struct {
Version string `json:"version"`
Services services `json:"services"`
Software software `json:"software"`
Protocols []string `json:"protocols"`
Usage usage `json:"usage"`
OpenRegistrations bool `json:"openRegistrations"`
Metadata metadata `json:"metadata"`
}

if !data.GetFederationEnabled() {
Expand All @@ -89,6 +98,10 @@ func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {

res := response{
Version: "2.0",
Services: services{
Inbound: []string{""},
Outbound: []string{""},
},
Software: software{
Name: "owncast",
Version: config.VersionNumber,
Expand All @@ -103,6 +116,9 @@ func NodeInfoV2Controller(w http.ResponseWriter, r *http.Request) {
},
OpenRegistrations: false,
Protocols: []string{"activitypub"},
Metadata: metadata{
ChatEnabled: !data.GetChatDisabled(),
},
}

if err := writeResponse(res, w); err != nil {
Expand Down

0 comments on commit 10cdf3d

Please sign in to comment.