1 Commits
Author SHA1 Message Date
Matt Baer 9a8df9b800 Add activitystreams.ActorActivity for Actor updates 2026-07-22 15:10:26 -04:00
+36
View File
@@ -4,6 +4,8 @@ package activitystreams
import (
"time"
"github.com/writeas/web-core/id"
)
const (
@@ -79,6 +81,40 @@ func NewUpdateActivity(o *Object) *Activity {
return &a
}
// ActorActivity describes an action whose object is a full actor (Person),
// such as an Update to a profile's name, summary, or icon. It parallels
// Activity, which instead carries a content *Object.
type ActorActivity struct {
BaseObject
Actor string `json:"actor"`
Updated *time.Time `json:"updated,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Object *Person `json:"object"`
}
// NewUpdateActorActivity builds an Update activity whose object is the given
// actor (Person), used to federate profile changes such as the actor's name,
// summary, or icon. It addresses the public namespace and CCs the actor's
// followers collection. The activity gets a unique ID derived from the actor's
// IRI so remote instances don't dedupe repeated updates against one another.
func NewUpdateActorActivity(p *Person) *ActorActivity {
a := ActorActivity{
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
},
ID: p.ID + "#update-" + id.GenerateFriendlyRandomString(20),
Type: "Update",
},
Actor: p.ID,
To: []string{ToPublic},
CC: []string{p.Followers},
Object: p,
}
return &a
}
// NewDeleteActivity builds a basic Delete activity that includes the given
// Object and the Object's AttributedTo property as the Actor.
func NewDeleteActivity(o *Object) *Activity {