From 63de2e6491f00a137c6fdedd01f6fdb101714b19 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Fri, 17 Aug 2018 20:42:39 -0400 Subject: [PATCH] Support creating Follow activities --- activitystreams/activity.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/activitystreams/activity.go b/activitystreams/activity.go index bf77c79..aab4c9f 100644 --- a/activitystreams/activity.go +++ b/activitystreams/activity.go @@ -22,6 +22,15 @@ type Activity struct { Object *Object `json:"object"` } +type FollowActivity struct { + BaseObject + Actor string `json:"actor"` + Published time.Time `json:"published,omitempty"` + To []string `json:"to,omitempty"` + CC []string `json:"cc,omitempty"` + Object string `json:"object"` +} + // NewCreateActivity builds a basic Create activity that includes the given // Object and the Object's AttributedTo property as the Actor. func NewCreateActivity(o *Object) *Activity { @@ -75,6 +84,21 @@ func NewDeleteActivity(o *Object) *Activity { return &a } +// NewFollowActivity builds a basic Follow activity. +func NewFollowActivity(actorIRI, followeeIRI string) *FollowActivity { + a := FollowActivity{ + BaseObject: BaseObject{ + Context: []interface{}{ + Namespace, + }, + Type: "Follow", + }, + Actor: actorIRI, + Object: followeeIRI, + } + return &a +} + // Object is the primary base type for the Activity Streams vocabulary. type Object struct { BaseObject