2020-11-17 16:10:14 +00:00
|
|
|
package main
|
|
|
|
|
2021-01-21 16:59:47 +00:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
2021-06-18 12:32:03 +00:00
|
|
|
|
2021-06-28 20:17:18 +00:00
|
|
|
"go.goblog.app/app/pkgs/contenttype"
|
2020-11-17 16:10:14 +00:00
|
|
|
)
|
|
|
|
|
2021-06-06 12:39:42 +00:00
|
|
|
func (a *goBlog) serveNodeInfoDiscover(w http.ResponseWriter, r *http.Request) {
|
2021-02-16 15:26:21 +00:00
|
|
|
b, _ := json.Marshal(map[string]interface{}{
|
2021-01-21 16:59:47 +00:00
|
|
|
"links": []map[string]interface{}{
|
|
|
|
{
|
2021-06-10 20:09:50 +00:00
|
|
|
"href": a.getFullAddress("/nodeinfo"),
|
2021-01-21 16:59:47 +00:00
|
|
|
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.1",
|
2020-11-17 16:10:14 +00:00
|
|
|
},
|
|
|
|
},
|
2021-02-16 15:26:21 +00:00
|
|
|
})
|
2021-06-18 12:32:03 +00:00
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
_, _ = a.min.Write(w, contenttype.JSON, b)
|
2020-11-17 16:10:14 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 12:39:42 +00:00
|
|
|
func (a *goBlog) serveNodeInfo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
localPosts, _ := a.db.countPosts(&postsRequestConfig{
|
2021-01-15 20:56:46 +00:00
|
|
|
status: statusPublished,
|
|
|
|
})
|
2021-02-16 15:26:21 +00:00
|
|
|
b, _ := json.Marshal(map[string]interface{}{
|
2021-01-21 16:59:47 +00:00
|
|
|
"version": "2.1",
|
|
|
|
"software": map[string]interface{}{
|
|
|
|
"name": "goblog",
|
2021-06-28 20:17:18 +00:00
|
|
|
"repository": "https://go.goblog.app/app",
|
2021-01-21 16:59:47 +00:00
|
|
|
},
|
|
|
|
"usage": map[string]interface{}{
|
|
|
|
"users": map[string]interface{}{
|
2021-06-06 12:39:42 +00:00
|
|
|
"total": len(a.cfg.Blogs),
|
2021-01-21 16:59:47 +00:00
|
|
|
},
|
|
|
|
"localPosts": localPosts,
|
|
|
|
},
|
|
|
|
"protocols": []string{
|
|
|
|
"activitypub",
|
|
|
|
"micropub",
|
|
|
|
"webmention",
|
2020-11-17 16:10:14 +00:00
|
|
|
},
|
2021-01-21 16:59:47 +00:00
|
|
|
"metadata": map[string]interface{}{},
|
2021-02-16 15:26:21 +00:00
|
|
|
})
|
2021-06-18 12:32:03 +00:00
|
|
|
w.Header().Set(contentType, contenttype.JSONUTF8)
|
|
|
|
_, _ = a.min.Write(w, contenttype.JSON, b)
|
2020-11-17 16:10:14 +00:00
|
|
|
}
|