MCPcopy
hub / github.com/writefreely/writefreely / handleFetchCollectionInbox

Function handleFetchCollectionInbox

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

Source from the content-addressed store, hash-verified

315}
316
317func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request) error {
318 w.Header().Set("Server", serverSoftware)
319
320 vars := mux.Vars(r)
321 alias := vars["alias"]
322 var c *Collection
323 var err error
324 if app.cfg.App.SingleUser {
325 c, err = app.db.GetCollectionByID(1)
326 } else {
327 c, err = app.db.GetCollection(alias)
328 }
329 if err != nil {
330 // TODO: return Reject?
331 return err
332 }
333 silenced, err := app.db.IsUserSilenced(c.OwnerID)
334 if err != nil {
335 log.Error("fetch collection inbox: %v", err)
336 return ErrInternalGeneral
337 }
338 if silenced {
339 return ErrCollectionNotFound
340 }
341 c.hostName = app.cfg.App.Host
342
343 if debugging {
344 dump, err := httputil.DumpRequest(r, true)
345 if err != nil {
346 log.Error("Can't dump: %v", err)
347 } else {
348 log.Info("Rec'd! %q", dump)
349 }
350 }
351
352 var m map[string]interface{}
353 if err := json.NewDecoder(r.Body).Decode(&m); err != nil {
354 return err
355 }
356
357 a := streams.NewAccept()
358 p := c.PersonObject()
359 var to *url.URL
360 var isFollow, isUnfollow, isLike, isUnlike bool
361 var likePostID, unlikePostID string
362 fullActor := &activitystreams.Person{}
363 var remoteUser *RemoteUser
364
365 res := &streams.Resolver{
366 LikeCallback: func(l *streams.Like) error {
367 isLike = true
368
369 // 1) Use the Like concrete type here
370 // 2) Errors are propagated to res.Deserialize call below
371 m["@context"] = []string{activitystreams.Namespace}
372 b, _ := json.Marshal(m)
373 if debugging {
374 log.Info("Like: %s", b)

Callers

nothing calls this directly

Calls 14

PersonObjectMethod · 0.95
FederatedAccountMethod · 0.95
AsPersonMethod · 0.95
parsePostIDFromURLFunction · 0.85
getActorFunction · 0.85
getRemoteUserFunction · 0.85
apAddRemoteUserFunction · 0.85
makeActivityPostFunction · 0.85
IsUserSilencedMethod · 0.80
StringMethod · 0.80
GetCollectionByIDMethod · 0.65
GetCollectionMethod · 0.65

Tested by

no test coverage detected