From 23cea380b0d2a1e205e84614e440ff77cf3a9fc6 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 25 Apr 2019 00:35:19 -0400 Subject: [PATCH] add empty follow collections --- activity.go | 2 ++ honk.go | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/activity.go b/activity.go index c1c0671..23b1332 100644 --- a/activity.go +++ b/activity.go @@ -695,6 +695,8 @@ func asjonker(user *WhatAbout) map[string]interface{} { j["type"] = "Person" j["inbox"] = user.URL + "/inbox" j["outbox"] = user.URL + "/outbox" + j["followers"] = user.URL + "/followers" + j["following"] = user.URL + "/following" j["name"] = user.Display j["preferredUsername"] = user.Name j["summary"] = about diff --git a/honk.go b/honk.go index 0c673bd..a262c4b 100644 --- a/honk.go +++ b/honk.go @@ -395,6 +395,29 @@ func outbox(w http.ResponseWriter, r *http.Request) { WriteJunk(w, j) } +func emptiness(w http.ResponseWriter, r *http.Request) { + name := mux.Vars(r)["name"] + user, err := butwhatabout(name) + if err != nil { + http.NotFound(w, r) + return + } + colname := "/followers" + if strings.HasSuffix(r.URL.Path, "/following") { + colname = "/following" + } + j := NewJunk() + j["@context"] = itiswhatitis + j["id"] = user.URL + colname + j["type"] = "OrderedCollection" + j["totalItems"] = 0 + j["orderedItems"] = []interface{}{} + + w.Header().Set("Cache-Control", "max-age=60") + w.Header().Set("Content-Type", theonetruename) + WriteJunk(w, j) +} + func viewuser(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] user, err := butwhatabout(name) @@ -1135,6 +1158,8 @@ func serve() { getters.HandleFunc("/u/{name:[[:alnum:]]+}/rss", showrss) posters.HandleFunc("/u/{name:[[:alnum:]]+}/inbox", inbox) getters.HandleFunc("/u/{name:[[:alnum:]]+}/outbox", outbox) + getters.HandleFunc("/u/{name:[[:alnum:]]+}/followers", emptiness) + getters.HandleFunc("/u/{name:[[:alnum:]]+}/following", emptiness) getters.HandleFunc("/a", avatate) getters.HandleFunc("/t", viewconvoy) getters.HandleFunc("/d/{xid:[[:alnum:].]+}", servefile)