Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a8df9b800 |
@@ -4,6 +4,8 @@ package activitystreams
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/writeas/web-core/id"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -79,6 +81,40 @@ func NewUpdateActivity(o *Object) *Activity {
|
|||||||
return &a
|
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
|
// NewDeleteActivity builds a basic Delete activity that includes the given
|
||||||
// Object and the Object's AttributedTo property as the Actor.
|
// Object and the Object's AttributedTo property as the Actor.
|
||||||
func NewDeleteActivity(o *Object) *Activity {
|
func NewDeleteActivity(o *Object) *Activity {
|
||||||
|
|||||||
Reference in New Issue
Block a user