MCPcopy Create free account
hub / github.com/davecheney/pub / Following

Function Following

activitypub/activitypub.go:55–73  ·  view source on GitHub ↗
(env *Env, w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

53 var following []*models.Relationship
54 query := env.DB.Joins("JOIN actors ON actors.id = relationships.actor_id and actors.name = ? and actors.domain = ?", chi.URLParam(r, "name"), r.Host)
55 if err := query.Model(&models.Relationship{}).Preload("Target").Find(&following, "following = true").Error; err != nil {
56 return err
57 }
58 return to.JSON(w, map[string]any{
59 "@context": "https://www.w3.org/ns/activitystreams",
60 "id": fmt.Sprintf("https://%s%s", r.Host, r.URL.Path),
61 "type": "OrderedCollection",
62 "totalItems": len(following),
63 "orderedItems": algorithms.Map(
64 following,
65 func(r *models.Relationship) string {
66 return r.Target.URI
67 },
68 ),
69 })
70}
71
72func CollectionsShow(env *Env, w http.ResponseWriter, r *http.Request) error {
73 var actor models.Actor
74 if err := env.DB.Take(&actor, "name = ? and domain = ?", chi.URLParam(r, "name"), r.Host).Error; err != nil {
75 if errors.Is(err, gorm.ErrRecordNotFound) {
76 return httpx.Error(http.StatusNotFound, err)

Callers

nothing calls this directly

Calls 4

JSONFunction · 0.92
MapFunction · 0.92
FindMethod · 0.80
URIMethod · 0.45

Tested by

no test coverage detected