MCPcopy
hub / github.com/writefreely/writefreely / handleFetchCollectionActivities

Function handleFetchCollectionActivities

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

Source from the content-addressed store, hash-verified

110}
111
112func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Request) error {
113 w.Header().Set("Server", serverSoftware)
114
115 vars := mux.Vars(r)
116 alias := vars["alias"]
117 if alias == "" {
118 alias = filepath.Base(r.RequestURI)
119 }
120
121 // TODO: enforce visibility
122 // Get base Collection data
123 var c *Collection
124 var err error
125 if alias == r.Host {
126 c = instanceColl
127 } else if app.cfg.App.SingleUser {
128 c, err = app.db.GetCollectionByID(1)
129 } else {
130 c, err = app.db.GetCollection(alias)
131 }
132 if err != nil {
133 return err
134 }
135 c.hostName = app.cfg.App.Host
136
137 if !c.IsInstanceColl() {
138 silenced, err := app.db.IsUserSilenced(c.OwnerID)
139 if err != nil {
140 log.Error("fetch collection activities: %v", err)
141 return ErrInternalGeneral
142 }
143 if silenced {
144 return ErrCollectionNotFound
145 }
146 }
147
148 p := c.PersonObject()
149
150 setCacheControl(w, apCacheTime)
151 return impart.RenderActivityJSON(w, p, http.StatusOK)
152}
153
154func handleFetchCollectionOutbox(app *App, w http.ResponseWriter, r *http.Request) error {
155 w.Header().Set("Server", serverSoftware)

Callers 1

fetchCollectionFunction · 0.85

Calls 6

IsInstanceCollMethod · 0.95
PersonObjectMethod · 0.95
setCacheControlFunction · 0.85
IsUserSilencedMethod · 0.80
GetCollectionByIDMethod · 0.65
GetCollectionMethod · 0.65

Tested by

no test coverage detected