2018-06-22 16:42:38 -04:00
|
|
|
package activitystreams
|
|
|
|
|
|
2018-06-24 21:06:26 -04:00
|
|
|
import "fmt"
|
|
|
|
|
|
2018-06-22 16:42:38 -04:00
|
|
|
type (
|
2018-06-22 17:11:07 -04:00
|
|
|
BaseObject struct {
|
|
|
|
|
Context []string `json:"@context"`
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-22 16:42:38 -04:00
|
|
|
PublicKey struct {
|
|
|
|
|
ID string `json:"id"`
|
|
|
|
|
Owner string `json:"owner"`
|
|
|
|
|
PublicKeyPEM string `json:"publicKeyPem"`
|
2018-06-25 11:32:12 -04:00
|
|
|
privateKey []byte
|
2018-06-22 16:42:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image struct {
|
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
MediaType string `json:"mediaType"`
|
|
|
|
|
URL string `json:"url"`
|
|
|
|
|
}
|
|
|
|
|
)
|
2018-06-22 17:11:07 -04:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2018-06-24 21:06:26 -04:00
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|