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

Method processRemovePin

activitypub/inbox.go:226–258  ·  view source on GitHub ↗
(act map[string]any)

Source from the content-addressed store, hash-verified

224 default:
225 return errors.New("add pin: unknown target: " + act.Target)
226 }
227}
228
229func (i *inboxProcessor) processRemove(act *Activity) error {
230 switch obj := act.Object.(type) {
231 case string:
232 return i.processRemovePin(act)
233 default:
234 return fmt.Errorf("processRemove: unknown type: %T", obj)
235 }
236}
237
238func (i *inboxProcessor) processRemovePin(act *Activity) error {
239 actor := stringFromAny(act.Actor)
240 switch act.Target {
241 case actor + "/collections/featured":
242 status, err := models.NewStatuses(i.db).FindByURI(stringFromAny(act.Object))
243 if err != nil {
244 return err
245 }
246 actor, err := models.NewActors(i.db).FindByURI(actor)
247 if err != nil {
248 return err
249 }
250 if status.ActorID != actor.ID {
251 return errors.New("actor is not the author of the status")
252 }
253 reactions := models.NewReactions(i.db)
254 _, err = reactions.Unpin(status, actor)
255 return err
256 default:
257 return errors.New("remove pin: unknown target: " + act.Target)
258 }
259}
260
261func (i *inboxProcessor) processCreate(create map[string]any) error {

Callers 1

processRemoveMethod · 0.95

Calls 5

UnpinMethod · 0.95
NewStatusesFunction · 0.92
NewActorsFunction · 0.92
NewReactionsFunction · 0.92
FindByURIMethod · 0.45

Tested by

no test coverage detected