MCPcopy
hub / github.com/writefreely/writefreely / handleFetchCollectionFollowing

Function handleFetchCollectionFollowing

activitypub.go:272–315  ·  view source on GitHub ↗
(app *App, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

270}
271
272func handleFetchCollectionFollowing(app *App, w http.ResponseWriter, r *http.Request) error {
273 w.Header().Set("Server", serverSoftware)
274
275 vars := mux.Vars(r)
276 alias := vars["alias"]
277
278 // TODO: enforce visibility
279 // Get base Collection data
280 var c *Collection
281 var err error
282 if app.cfg.App.SingleUser {
283 c, err = app.db.GetCollectionByID(1)
284 } else {
285 c, err = app.db.GetCollection(alias)
286 }
287 if err != nil {
288 return err
289 }
290 silenced, err := app.db.IsUserSilenced(c.OwnerID)
291 if err != nil {
292 log.Error("fetch collection following: %v", err)
293 return ErrInternalGeneral
294 }
295 if silenced {
296 return ErrCollectionNotFound
297 }
298 c.hostName = app.cfg.App.Host
299
300 accountRoot := c.FederatedAccount()
301
302 page := r.FormValue("page")
303 p, err := strconv.Atoi(page)
304 if err != nil || p < 1 {
305 // Return outbox
306 oc := activitystreams.NewOrderedCollection(accountRoot, "following", 0)
307 return impart.RenderActivityJSON(w, oc, http.StatusOK)
308 }
309
310 // Return outbox page
311 ocp := activitystreams.NewOrderedCollectionPage(accountRoot, "following", 0, p)
312 ocp.OrderedItems = []interface{}{}
313 setCacheControl(w, apCacheTime)
314 return impart.RenderActivityJSON(w, ocp, http.StatusOK)
315}
316
317func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request) error {
318 w.Header().Set("Server", serverSoftware)

Callers

nothing calls this directly

Calls 5

FederatedAccountMethod · 0.95
setCacheControlFunction · 0.85
IsUserSilencedMethod · 0.80
GetCollectionByIDMethod · 0.65
GetCollectionMethod · 0.65

Tested by

no test coverage detected