2022-11-30 05:43:31 +00:00
|
|
|
package activitypub
|
|
|
|
|
|
|
|
import "encoding/json"
|
|
|
|
|
|
|
|
type OrderedCollection struct {
|
|
|
|
Context string `json:"@context"`
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
Type string `json:"type,omitempty"`
|
|
|
|
TotalItems int `json:"totalItems"`
|
|
|
|
OrderedItems interface{} `json:"orderedItems,omitempty"`
|
|
|
|
First string `json:"first,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewOrderedCollection(id string, items interface{}, length int) *OrderedCollection {
|
|
|
|
return &OrderedCollection{
|
|
|
|
Context: ActivityStreams,
|
|
|
|
ID: id,
|
|
|
|
Type: TypeOrderedCollection,
|
|
|
|
TotalItems: length,
|
|
|
|
OrderedItems: items,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func UnmarshalOrderedCollection(data []byte) (OrderedCollection, error) {
|
2023-05-03 14:41:06 +00:00
|
|
|
var orderedCollection OrderedCollection
|
|
|
|
err := json.Unmarshal(data, &orderedCollection)
|
|
|
|
return orderedCollection, err
|
2022-11-30 05:43:31 +00:00
|
|
|
}
|
|
|
|
|
2023-05-03 14:41:06 +00:00
|
|
|
func (orderedCollection *OrderedCollection) Marshal() ([]byte, error) {
|
|
|
|
return json.Marshal(orderedCollection)
|
2022-11-30 05:43:31 +00:00
|
|
|
}
|