Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F10668890
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
View Options
diff --git a/activitystreams/activity.go b/activitystreams/activity.go
index b1a5340..a94de75 100644
--- a/activitystreams/activity.go
+++ b/activitystreams/activity.go
@@ -1,71 +1,72 @@
package activitystreams
import (
"time"
)
const (
- toPublic = "https://www.w3.org/ns/activitystreams#Public"
+ Namespace = "https://www.w3.org/ns/activitystreams"
+ toPublic = "https://www.w3.org/ns/activitystreams#Public"
)
type Activity struct {
BaseObject
Actor string `json:"actor"`
Published time.Time `json:"published,omitempty"`
To []string `json:"to,omitempty"`
CC []string `json:"cc,omitempty"`
Object *Object `json:"object"`
}
func NewCreateActivity(o *Object) *Activity {
a := Activity{
BaseObject: BaseObject{
Context: []interface{}{
- "https://www.w3.org/ns/activitystreams",
+ Namespace,
},
ID: o.ID + "/activity",
Type: "Create",
},
Actor: o.AttributedTo,
Object: o,
}
return &a
}
type Object struct {
BaseObject
Published time.Time `json:"published"`
Summary *string `json:"summary,omitempty"`
InReplyTo *string `json:"inReplyTo"`
URL string `json:"url"`
AttributedTo string `json:"attributedTo"`
To []string `json:"to"`
CC []string `json:"cc,omitempty"`
Name string `json:"name,omitempty"`
Content string `json:"content"`
ContentMap map[string]string `json:"contentMap,omitempty"`
}
func NewNoteObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Note",
},
To: []string{
toPublic,
},
}
return &o
}
func NewArticleObject() *Object {
o := Object{
BaseObject: BaseObject{
Type: "Article",
},
To: []string{
toPublic,
},
}
return &o
}
diff --git a/activitystreams/data.go b/activitystreams/data.go
index e107d36..4197171 100644
--- a/activitystreams/data.go
+++ b/activitystreams/data.go
@@ -1,75 +1,75 @@
package activitystreams
import "fmt"
type (
BaseObject struct {
Context []interface{} `json:"@context,omitempty"`
Type string `json:"type"`
ID string `json:"id"`
}
PublicKey struct {
ID string `json:"id"`
Owner string `json:"owner"`
PublicKeyPEM string `json:"publicKeyPem"`
privateKey []byte
}
Endpoints struct {
SharedInbox string `json:"sharedInbox"`
}
Image struct {
Type string `json:"type"`
MediaType string `json:"mediaType"`
URL string `json:"url"`
}
)
type OrderedCollection struct {
BaseObject
TotalItems int `json:"totalItems"`
First string `json:"first"`
Last string `json:"last,omitempty"`
}
func NewOrderedCollection(accountRoot, collType string, items int) *OrderedCollection {
oc := OrderedCollection{
BaseObject: BaseObject{
Context: []interface{}{
- "https://www.w3.org/ns/activitystreams",
+ Namespace,
},
ID: accountRoot + "/" + collType,
Type: "OrderedCollection",
},
First: accountRoot + "/" + collType + "?page=1",
TotalItems: items,
}
return &oc
}
type OrderedCollectionPage struct {
BaseObject
TotalItems int `json:"totalItems"`
PartOf string `json:"partOf"`
Next string `json:"next,omitempty"`
Prev string `json:"prev,omitempty"`
OrderedItems []Activity `json:"orderedItems"`
}
func NewOrderedCollectionPage(accountRoot, collType string, items, page int) *OrderedCollectionPage {
ocp := OrderedCollectionPage{
BaseObject: BaseObject{
Context: []interface{}{
- "https://www.w3.org/ns/activitystreams",
+ Namespace,
},
ID: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page),
Type: "OrderedCollectionPage",
},
TotalItems: items,
PartOf: accountRoot + "/" + collType,
Next: fmt.Sprintf("%s/%s?page=%d", accountRoot, collType, page+1),
}
return &ocp
}
diff --git a/activitystreams/person.go b/activitystreams/person.go
index 7b93726..b878d2c 100644
--- a/activitystreams/person.go
+++ b/activitystreams/person.go
@@ -1,51 +1,51 @@
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"`
}
func NewPerson(accountRoot string) *Person {
p := Person{
BaseObject: BaseObject{
Type: "Person",
Context: []interface{}{
- "https://www.w3.org/ns/activitystreams",
+ 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
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, May 15, 11:04 AM (18 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3238969
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment