Browse Source

Add BaseObject

master
Matt Baer 5 years ago
parent
commit
e7db291bd3
2 changed files with 35 additions and 7 deletions
  1. +28
    -0
      activitystreams/data.go
  2. +7
    -7
      activitystreams/person.go

+ 28
- 0
activitystreams/data.go View File

@@ -1,6 +1,12 @@
package activitystreams

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"`
@@ -13,3 +19,25 @@ type (
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
}

+ 7
- 7
activitystreams/person.go View File

@@ -1,9 +1,7 @@
package activitystreams

type Person struct {
Context []string `json:"@context"`
Type string `json:"type"`
ID string `json:"id"`
BaseObject
Inbox string `json:"inbox"`
Outbox string `json:"outbox"`
PreferredUsername string `json:"preferredUsername"`
@@ -18,11 +16,13 @@ type Person struct {

func NewPerson(accountRoot string) *Person {
p := Person{
Type: "Person",
Context: []string{
"https://www.w3.org/ns/activitystreams",
BaseObject: BaseObject{
Type: "Person",
Context: []string{
"https://www.w3.org/ns/activitystreams",
},
ID: accountRoot,
},
ID: accountRoot,
URL: accountRoot,
Following: accountRoot + "/following",
Followers: accountRoot + "/followers",


Loading…
Cancel
Save