Page MenuHomeMusing Studio

No OneTemporary

diff --git a/activitystreams/activity.go b/activitystreams/activity.go
index 915ae56..81da084 100644
--- a/activitystreams/activity.go
+++ b/activitystreams/activity.go
@@ -1,178 +1,184 @@
// Package activitystreams provides all the basic ActivityStreams
// implementation needed for Write.as.
package activitystreams
import (
"time"
)
const (
Namespace = "https://www.w3.org/ns/activitystreams"
toPublic = "https://www.w3.org/ns/activitystreams#Public"
)
-var Extensions = map[string]string{}
+var (
+ Extensions = map[string]string{}
+
+ apMonetizationContext = map[string]interface{}{
+ "monetization": "https://interledger.org/ns#monetization",
+ }
+)
// Activity describes actions that have either already occurred, are in the
// process of occurring, or may occur in the future.
type Activity struct {
BaseObject
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
Updated *time.Time `json:"updated,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
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 {
a := Activity{
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
Extensions,
},
ID: o.ID,
Type: "Create",
},
Actor: o.AttributedTo,
Object: o,
Published: o.Published,
}
return &a
}
// NewUpdateActivity builds a basic Update activity that includes the given
// Object and the Object's AttributedTo property as the Actor.
func NewUpdateActivity(o *Object) *Activity {
a := Activity{
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
Extensions,
},
ID: o.ID,
Type: "Update",
},
Actor: o.AttributedTo,
Object: o,
Published: o.Published,
}
if o.Updated != nil && !o.Updated.IsZero() {
a.Updated = o.Updated
}
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 {
a := Activity{
BaseObject: BaseObject{
Context: []interface{}{
Namespace,
},
ID: o.ID,
Type: "Delete",
},
Actor: o.AttributedTo,
Object: o,
}
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
Published time.Time `json:"published,omitempty"`
Updated *time.Time `json:"updated,omitempty"`
Summary *string `json:"summary,omitempty"`
InReplyTo *string `json:"inReplyTo,omitempty"`
URL string `json:"url"`
AttributedTo string `json:"attributedTo,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content,omitempty"`
ContentMap map[string]string `json:"contentMap,omitempty"`
Tag []Tag `json:"tag,omitempty"`
Attachment []Attachment `json:"attachment,omitempty"`
Preview *Object `json:"preview,omitempty"`
// Person
Inbox string `json:"inbox,omitempty"`
Outbox string `json:"outbox,omitempty"`
Following string `json:"following,omitempty"`
Followers string `json:"followers,omitempty"`
PreferredUsername string `json:"preferredUsername,omitempty"`
Icon *Image `json:"icon,omitempty"`
PublicKey *PublicKey `json:"publicKey,omitempty"`
Endpoints *Endpoints `json:"endpoints,omitempty"`
// Extensions
// NOTE: add extensions here
}
// NewNoteObject creates a basic Note object that includes the public
// namespace in IRIs it's addressed to.
func NewNoteObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Note",
},
To: []string{
toPublic,
},
}
return &o
}
// NewArticleObject creates a basic Article object that includes the public
// namespace in IRIs it's addressed to.
func NewArticleObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Article",
},
To: []string{
toPublic,
},
}
return &o
}
// NewPersonObject creates a basic Person object.
func NewPersonObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Person",
},
}
return &o
}
diff --git a/activitystreams/person.go b/activitystreams/person.go
index b878d2c..f359b80 100644
--- a/activitystreams/person.go
+++ b/activitystreams/person.go
@@ -1,51 +1,59 @@
package activitystreams
type Person struct {
BaseObject
Inbox string `json:"inbox"`
Outbox string `json:"outbox"`
PreferredUsername string `json:"preferredUsername"`
URL string `json:"url"`
Name string `json:"name"`
Icon Image `json:"icon"`
Following string `json:"following"`
Followers string `json:"followers"`
Summary string `json:"summary"`
PublicKey PublicKey `json:"publicKey"`
Endpoints Endpoints `json:"endpoints"`
+
+ // Extensions
+ Monetization string `json:"monetization,omitempty"`
}
func NewPerson(accountRoot string) *Person {
p := Person{
BaseObject: BaseObject{
Type: "Person",
Context: []interface{}{
Namespace,
},
ID: accountRoot,
},
Following: accountRoot + "/following",
Followers: accountRoot + "/followers",
Inbox: accountRoot + "/inbox",
Outbox: accountRoot + "/outbox",
}
return &p
}
func (p *Person) AddPubKey(k []byte) {
p.Context = append(p.Context, "https://w3id.org/security/v1")
p.PublicKey = PublicKey{
ID: p.ID + "#main-key",
Owner: p.ID,
PublicKeyPEM: string(k),
}
}
func (p *Person) SetPrivKey(k []byte) {
p.PublicKey.privateKey = k
}
func (p *Person) GetPrivKey() []byte {
return p.PublicKey.privateKey
}
+
+func (p *Person) AddWebMonetization(wallet string) {
+ p.Context = append(p.Context, apMonetizationContext)
+ p.Monetization = wallet
+}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Jan 30, 12:13 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3609968

Event Timeline