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

Method Create

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

Source from the content-addressed store, hash-verified

28
29type InboxController struct {
30 db *gorm.DB
31}
32
33func (i *InboxController) Create(env *Env, w http.ResponseWriter, r *http.Request) error {
34 instance, err := i.findInstance(r.Host)
35 if err != nil {
36 return err
37 }
38
39 var act Activity
40 if err := json.UnmarshalFull(r.Body, &act); err != nil {
41 return httpx.Error(http.StatusBadRequest, err)
42 }
43
44 // if we need to make an activity pub request, we need to sign it with the
45 // instance's admin account.
46 processor := &inboxProcessor{
47 logger: env.Logger.With("instance", instance.Domain),
48 req: r,
49 db: i.db,
50 signAs: instance.Admin,
51 }
52
53 if err := processor.processActivity(&act); err != nil {
54 return fmt.Errorf("processActivity failed: %s: %w ", act.ID, err)
55 }
56 w.WriteHeader(http.StatusAccepted)
57 return nil

Callers

nothing calls this directly

Calls 3

processActivityMethod · 0.95
ErrorFunction · 0.92
WriteHeaderMethod · 0.80

Tested by

no test coverage detected