Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F14964613
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Subscribers
None
View Options
diff --git a/activitystreams/activity.go b/activitystreams/activity.go
new file mode 100644
index 0000000..95f2bf1
--- /dev/null
+++ b/activitystreams/activity.go
@@ -0,0 +1,58 @@
+package activitystreams
+
+import (
+ "time"
+)
+
+const (
+ toPublic = "https://www.w3.org/ns/activitystreams#Public"
+)
+
+type Activity struct {
+ BaseObject
+ Actor string `json:"actor"`
+ Published time.Time `json:"published"`
+ To []string `json:"to"`
+ CC []string `json:"cc"`
+ Object *Object `json:"object"`
+}
+
+func NewCreateActivity(o *Object) *Activity {
+ a := Activity{
+ BaseObject: BaseObject{
+ ID: o.ID + "/activity",
+ Type: "Create",
+ },
+ Actor: o.AttributedTo,
+ Published: o.Published,
+ To: o.To,
+ CC: o.CC,
+ Object: o,
+ }
+ return &a
+}
+
+type Object struct {
+ BaseObject
+ Published time.Time `json:"published"`
+ Summary *string `json:"summary"`
+ InReplyTo *string `json:"inReplyTo"`
+ URL string `json:"url"`
+ AttributedTo string `json:"attributedTo"`
+ To []string `json:"to"`
+ CC []string `json:"cc"`
+ Content string `json:"content"`
+ ContentMap map[string]string `json:"contentMap"`
+}
+
+func NewNoteObject() *Object {
+ o := Object{
+ BaseObject: BaseObject{
+ Type: "Note",
+ },
+ To: []string{
+ toPublic,
+ },
+ }
+ return &o
+}
diff --git a/activitystreams/data.go b/activitystreams/data.go
index d3453a3..af5bedd 100644
--- a/activitystreams/data.go
+++ b/activitystreams/data.go
@@ -1,43 +1,70 @@
package activitystreams
+import "fmt"
+
type (
BaseObject struct {
Context []string `json:"@context"`
Type string `json:"type"`
ID string `json:"id"`
}
PublicKey struct {
ID string `json:"id"`
Owner string `json:"owner"`
PublicKeyPEM string `json:"publicKeyPem"`
}
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 string, items int) *OrderedCollection {
oc := OrderedCollection{
BaseObject: BaseObject{
Context: []string{
"https://www.w3.org/ns/activitystreams",
},
ID: accountRoot + "/outbox",
Type: "OrderedCollection",
},
First: accountRoot + "/outbox?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 string, items, page int) *OrderedCollectionPage {
+ ocp := OrderedCollectionPage{
+ BaseObject: BaseObject{
+ Context: []string{
+ "https://www.w3.org/ns/activitystreams",
+ },
+ ID: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page),
+ Type: "OrderedCollectionPage",
+ },
+ TotalItems: items,
+ PartOf: accountRoot + "/outbox",
+ Next: fmt.Sprintf("%s/outbox?page=%d", accountRoot, page+1),
+ }
+ return &ocp
+}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Jul 29, 7:56 PM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3785091
Attached To
rWC Write.as Web Core
Event Timeline
Log In to Comment