Add BaseObject

This commit is contained in:
Matt Baer
2018-06-22 17:11:07 -04:00
parent e99c8d6b4d
commit e7db291bd3
2 changed files with 35 additions and 7 deletions
+28
View File
@@ -1,6 +1,12 @@
package activitystreams package activitystreams
type ( type (
BaseObject struct {
Context []string `json:"@context"`
Type string `json:"type"`
ID string `json:"id"`
}
PublicKey struct { PublicKey struct {
ID string `json:"id"` ID string `json:"id"`
Owner string `json:"owner"` Owner string `json:"owner"`
@@ -13,3 +19,25 @@ type (
URL string `json:"url"` 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
}
+3 -3
View File
@@ -1,9 +1,7 @@
package activitystreams package activitystreams
type Person struct { type Person struct {
Context []string `json:"@context"` BaseObject
Type string `json:"type"`
ID string `json:"id"`
Inbox string `json:"inbox"` Inbox string `json:"inbox"`
Outbox string `json:"outbox"` Outbox string `json:"outbox"`
PreferredUsername string `json:"preferredUsername"` PreferredUsername string `json:"preferredUsername"`
@@ -18,11 +16,13 @@ type Person struct {
func NewPerson(accountRoot string) *Person { func NewPerson(accountRoot string) *Person {
p := Person{ p := Person{
BaseObject: BaseObject{
Type: "Person", Type: "Person",
Context: []string{ Context: []string{
"https://www.w3.org/ns/activitystreams", "https://www.w3.org/ns/activitystreams",
}, },
ID: accountRoot, ID: accountRoot,
},
URL: accountRoot, URL: accountRoot,
Following: accountRoot + "/following", Following: accountRoot + "/following",
Followers: accountRoot + "/followers", Followers: accountRoot + "/followers",