streams

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 14

README

Hannibal / streams

This package implements the ActivityStreams 2.0 specifications in Hannibal. Specifically, it provides an overly simplistic view of JSON-LD documents, contexts, and the various types of ActivityStream collections.

This is not a rigorous implementation of JSON-LD. Instead, it is an easy way to navigate well-formatted JSON-LD documents and to iterate over their contents, as well as loading additional documents from the web when necessary.

// Load a document directly from its URL
document, err := streams.Load("https://your.activitypub.server/@documentId")

document.ID() // returns a string value
document.Content() // returns the content property
document.Published() // returns a time value

// AttributedTo could be many things.. a single value, a link, or
// an array of values and links. Let's make all of that easier.
authors := document.AttributedTo() 

// You could just read the first author directly
authors.Name() // returns the 'Name' string
authors.ID() // returns the 'ID' string

// Or you can use it as an iterator
for authors := document.AttributedTo ; !authors.IsNil() ; authors = authors.Tail() {
	authors.Value() // returns the whole value from the array
}

Documentation

Index

Constants

View Source
const OptionStripContext = "STRIP_CONTEXT"

OptionStripContext instructs the Document.Map() method to remove the "@context" property from its ouput.

View Source
const OptionStripRecipients = "STRIP_RECCIPIENTS"

OptionStripRecipients instructs the Document.Map() method to remove all recipient properties from its output. (To, BTo, CC, BCC)

Variables

This section is empty.

Functions

func UnmarshalItems

func UnmarshalItems(data any) ([]any, bool)

Types

type Client added in v0.4.0

type Client interface {

	// Load returns a Document representing the specified URI.
	Load(uri string, options ...any) (Document, error)
}

Client represents an HTTP client (or facades in front of one) that can load a JSON-LD document from a remote server. A Client is injected into each streams.Document record so that the Document can load additional linked data as needed.

func NewDefaultClient added in v0.4.0

func NewDefaultClient() Client

type Collection

type Collection struct {
	Context    Context `json:"@context,omitempty"    bson:"context,omitempty"`
	ID         string  `json:"id,omitempty"          bson:"id,omitempty"`
	Type       string  `json:"type,omitempty"        bson:"type,omitempty"`
	Summary    string  `json:"summary,omitempty"     bson:"summary,omitempty"`    // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems int     `json:"totalItems,omitempty"  bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current    string  `json:"current,omitempty"     bson:"current,omitempty"`    // In a paged Collection, indicates the page that contains the most recently updated member items.
	First      string  `json:"first,omitempty"       bson:"first,omitempty"`      // In a paged Collection, indicates the furthest preceding page of items in the collection.
	Last       string  `json:"last,omitempty"        bson:"last,omitempty"`       // In a paged Collection, indicates the furthest proceeding page of the collection.
	Items      []any   `json:"items,omitempty"       bson:"items,omitempty"`      // Identifies the items contained in a collection. The items might be ordered or unordered.
}

Collection is a subtype of Object that represents ordered or unordered sets of Object or Link instances. https://www.w3.org/ns/activitystreams#Collection

func NewCollection added in v0.3.0

func NewCollection() Collection

func (*Collection) UnmarshalJSON

func (c *Collection) UnmarshalJSON(data []byte) error

func (*Collection) UnmarshalMap

func (c *Collection) UnmarshalMap(data mapof.Any) error

type CollectionPage

type CollectionPage struct {
	Context    Context `json:"@context,omitempty"    bson:"context,omitempty"`
	Type       string  `json:"type,omitempty"        bson:"type,omitempty"`
	Summary    string  `json:"summary,omitempty"     bson:"summary,omitempty"`    // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems int     `json:"totalItems,omitempty"  bson:"totalItems,omitempty"` // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current    string  `json:"current,omitempty"     bson:"current,omitempty"`    // In a paged Collection, indicates the page that contains the most recently updated member items.
	First      string  `json:"first,omitempty"       bson:"first,omitempty"`      // In a paged Collection, indicates the furthest preceding page of items in the collection.
	Last       string  `json:"last,omitempty"        bson:"last,omitempty"`       // In a paged Collection, indicates the furthest proceeding page of the collection.
	PartOf     string  `json:"partOf,omitempty"      bson:"partOf,omitempty"`     // dentifies the Collection to which a CollectionPage objects items belong.
	Prev       string  `json:"prev,omitempty"        bson:"prev,omitempty"`       // In a paged Collection, identifies the previous page of items.
	Next       string  `json:"next,omitempty"        bson:"next,omitempty"`       // In a paged Collection, indicates the next page of items.
	Items      []any   `json:"items,omitempty"       bson:"items,omitempty"`      // Identifies the items contained in a collection. The items might be ordered or unordered.
}

CollectionPage is used to represent distinct subsets of items from a Collection. Refer to the Activity Streams 2.0 Core for a complete description of the CollectionPage object. https://www.w3.org/ns/activitystreams#CollectionPage

func NewCollectionPage added in v0.3.0

func NewCollectionPage() CollectionPage

func (*CollectionPage) UnmarshalJSON

func (c *CollectionPage) UnmarshalJSON(data []byte) error

*****************************************

  • JSON Marshalling *****************************************

func (*CollectionPage) UnmarshalMap

func (c *CollectionPage) UnmarshalMap(data mapof.Any) error

type Context

type Context []ContextEntry

func DefaultContext

func DefaultContext() Context

DefaultContext represents the standard context defined by the W3C

func NewContext

func NewContext(args ...string) Context

func (*Context) Add

func (c *Context) Add(vocabulary string) *ContextEntry

Add puts a new ContextEntry into the list and returns a pointer to it so that additional properties can be set.

func (Context) Head

func (c Context) Head() *ContextEntry

func (Context) IsEmpty

func (c Context) IsEmpty() bool

func (Context) IsEmptyTail

func (c Context) IsEmptyTail() bool

func (Context) Length

func (c Context) Length() int

func (Context) MarshalJSON

func (c Context) MarshalJSON() ([]byte, error)

func (Context) Tail

func (c Context) Tail() Context

func (*Context) UnmarshalJSON

func (c *Context) UnmarshalJSON(data []byte) error

type ContextEntry

type ContextEntry struct {
	Vocabulary string            // The primary vocabulary represented by the context/document.
	Language   string            // The language
	Extensions map[string]string // a map of additional namespaces that are included in this context/document.
}

ContextEntry https://www.w3.org/TR/json-ld/#the-context

func NewContextEntry

func NewContextEntry(vocabulary string) ContextEntry

func (ContextEntry) HasExtensions

func (entry ContextEntry) HasExtensions() bool

func (ContextEntry) IsLanguageDefined

func (entry ContextEntry) IsLanguageDefined() bool

func (ContextEntry) IsVocabularyOnly

func (entry ContextEntry) IsVocabularyOnly() bool

func (ContextEntry) MarshalJSON

func (entry ContextEntry) MarshalJSON() ([]byte, error)

func (*ContextEntry) WithExtension

func (entry *ContextEntry) WithExtension(key string, value string) *ContextEntry

func (*ContextEntry) WithLanguage

func (entry *ContextEntry) WithLanguage(language string) *ContextEntry

type DefaultClient added in v0.4.0

type DefaultClient struct{}

func (DefaultClient) Load added in v0.4.0

func (client DefaultClient) Load(url string, options ...any) (Document, error)

Load implements the hannibal.Client interface, which loads an ActivityStream document from a remote server. For the hannibal default client, this method simply loads the document from a remote server with no other processing.

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document represents a single ActivityStream document or document fragment. Due to the flexibility of ActivityStreams (and JSON-LD), this may be a data structure such as a `map[string]any`, `[]any`, or a primitive type, like a `string`, `float`, `int` or `bool`.

func NewDocument

func NewDocument(value any, options ...DocumentOption) Document

NewDocument creates a new Document object from a JSON-LD map[string]any

func NilDocument

func NilDocument(options ...DocumentOption) Document

NilDocument returns a new, empty Document.

func (*Document) Append added in v0.9.2

func (document *Document) Append(name string, value any) bool

Append appends a value to a property on the document

func (*Document) AppendBCC added in v0.8.1

func (document *Document) AppendBCC(value string) bool

AppendBCC appends a value to the "bcc" property of the document

func (*Document) AppendBTo added in v0.8.1

func (document *Document) AppendBTo(value string) bool

AppendBTo appends a value to the "bto" property of the document

func (*Document) AppendCC added in v0.8.1

func (document *Document) AppendCC(value string) bool

AppendCC appends a value to the "cc" property of the document

func (*Document) AppendString added in v0.8.1

func (document *Document) AppendString(name string, value string) bool

AppendString appends a string to a property on the document

func (*Document) AppendTo added in v0.8.1

func (document *Document) AppendTo(value string) bool

AppendTo appends a value to the "to" property of the document

func (Document) AspectRatio added in v0.9.2

func (document Document) AspectRatio() string

func (Document) AtContext added in v0.9.1

func (document Document) AtContext() Document

https://www.w3.org/TR/activitystreams-core/#h-jsonld

func (Document) BCC added in v0.8.1

func (document Document) BCC() Document

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bcc

func (Document) BTo added in v0.8.1

func (document Document) BTo() Document

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bto

func (Document) Blocked added in v0.5.0

func (document Document) Blocked() Document

func (Document) Bool added in v0.4.0

func (document Document) Bool() bool

Bool returns the current object as a floating-point value

func (Document) CC added in v0.8.1

func (document Document) CC() Document

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-cc

func (Document) Channel added in v0.8.1

func (document Document) Channel() <-chan Document

Channel returns a channel that iterates over all of the sub-documents in the current document.

func (*Document) Client added in v0.8.1

func (document *Document) Client() Client

Client returns the HTTP client used for this document

func (Document) Clone added in v0.7.0

func (document Document) Clone() Document

func (Document) Context

func (document Document) Context() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context IMPORTANT: THIS IS NOT THE @context PROPERTY REQUIRED FOR EVERY JSON-LD DOCUMENT

func (Document) Duration

func (document Document) Duration() string

TODO: Implement Durations per https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration

func (Document) Endpoints added in v0.7.0

func (document Document) Endpoints() Document

func (Document) Float added in v0.4.0

func (document Document) Float() float64

Float returns the current object as an integer value

func (Document) Followers added in v0.5.0

func (document Document) Followers() Document

https://www.w3.org/TR/activitypub/#followers

func (Document) Following added in v0.5.0

func (document Document) Following() Document

https://www.w3.org/TR/activitypub/#following

func (Document) Get

func (document Document) Get(key string) Document

Get returns a sub-property of the current document

func (Document) HTMLString added in v0.8.0

func (document Document) HTMLString() string

StringHTML returns the current object as an HTML string. This value is filtered by blueMonday, so it is safe to use in HTML.

func (Document) HTTPHeader added in v0.7.0

func (document Document) HTTPHeader() http.Header

HTTPHeader returns the http.Header object associated with this document

func (Document) HasContent added in v0.8.1

func (document Document) HasContent() bool

HasContent returns TRUE if this document has a valid Content property

func (Document) HasDimensions added in v0.9.2

func (document Document) HasDimensions() bool

func (Document) HasImage added in v0.8.1

func (document Document) HasImage() bool

HasImage returns TRUE if this document has a valid Image property

func (Document) HasSummary added in v0.8.1

func (document Document) HasSummary() bool

HasSummary returns TRUE if this document has a valid Summary property

func (Document) Head

func (document Document) Head() Document

Head returns the first object in a slice. For all other document types, it returns the current document.

func (Document) IconOrImage added in v0.4.2

func (document Document) IconOrImage() Image

IconOrImage is a hybrid accessor that returns the "icon" property (if not nil), otherwise it returns the "image" property. This is useful for working with different ActivityPub objects, which may use either property.

func (Document) ImageOrIcon added in v0.9.2

func (document Document) ImageOrIcon() Image

ImageOrIcon is a hybrid accessor that returns the "image" property (if not nil), otherwise it returns the "icon" property. This is useful for working with different ActivityPub objects, which may use either property.

func (Document) Inbox added in v0.5.0

func (document Document) Inbox() Document

https://www.w3.org/TR/activitypub/#inbox

func (Document) Int added in v0.4.0

func (document Document) Int() int

Int returns the current object as an integer value

func (Document) IsActivity added in v0.8.0

func (document Document) IsActivity() bool

IsActivity returns TRUE if this document represents an Activity

func (Document) IsActor added in v0.8.1

func (document Document) IsActor() bool

IsActor returns TRUE if this document represents an Actor

func (Document) IsBool

func (document Document) IsBool() bool

func (Document) IsCollection added in v0.9.0

func (document Document) IsCollection() bool

IsCollection returns TRUE if this document represents a Collection or CollectionPage

func (Document) IsEmptyTail

func (document Document) IsEmptyTail() bool

IsEmpty return TRUE if the current object is empty

func (Document) IsFloat

func (document Document) IsFloat() bool

func (Document) IsInt

func (document Document) IsInt() bool

func (Document) IsInt64

func (document Document) IsInt64() bool

func (Document) IsMap added in v0.4.2

func (document Document) IsMap() bool

func (Document) IsNil

func (document Document) IsNil() bool

func (Document) IsObject

func (document Document) IsObject() bool

IsObject returns TRUE if this document represents an Object type (Article, Note, etc)

func (Document) IsSlice added in v0.9.0

func (document Document) IsSlice() bool

func (Document) IsString

func (document Document) IsString() bool

func (Document) Items

func (document Document) Items() Document

Items returns the items collection for this Document. If the document contains an "orderedItems" collection, then it is returned instead.

func (Document) Len added in v0.5.0

func (document Document) Len() int

Len returns the length of the document. If the document is nil, then this method returns 0 If the document is a slice, then this method returns the length of the slice Otherwise, this method returns 1

func (Document) Liked added in v0.5.0

func (document Document) Liked() Document

https://www.w3.org/TR/activitypub/#liked

func (Document) Likes added in v0.8.0

func (document Document) Likes() Document

https://www.w3.org/TR/activitypub/#likes

func (Document) Load added in v0.4.0

func (document Document) Load(options ...any) (Document, error)

Load retrieves a JSON-LD document from its remote server

func (document Document) LoadLink(options ...any) Document

LoadLink loads a new JSON-LD document from a link or ID string. If the current document has already been loaded (because it's a map) then it is returned as-is.

func (Document) Map added in v0.4.2

func (document Document) Map(options ...string) map[string]any

func (Document) MapKeys added in v0.9.1

func (document Document) MapKeys() []string

func (Document) MarshalJSON

func (document Document) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface, and provides a custom marshalling into JSON -- essentially just aiming the marshaller at the Document's value.

func (Document) MustLoad added in v0.9.0

func (document Document) MustLoad(options ...any) Document

MustLoad retrieves a JSON-LD document from its remote server. It silently reports errors, but does not return them.

func (Document) NotActivity added in v0.9.0

func (document Document) NotActivity() bool

NotActivity returns TRUE if this document does NOT represent an Activity

func (Document) NotActor added in v0.9.0

func (document Document) NotActor() bool

NotActor returns TRUE if this document does NOT represent an Actor

func (Document) NotCollection added in v0.9.0

func (document Document) NotCollection() bool

NotCollection returns TRUE if the document does NOT represent a Collection or CollectionPage

func (Document) NotNil added in v0.4.2

func (document Document) NotNil() bool

func (Document) NotObject added in v0.9.0

func (document Document) NotObject() bool

NotObject returns TRUE if this document does NOT represent an Object type (Article, Note, etc)

func (Document) Outbox added in v0.5.0

func (document Document) Outbox() Document

https://www.w3.org/TR/activitypub/#outbox

func (Document) PreferredUsername added in v0.8.0

func (document Document) PreferredUsername() string

func (Document) PublicKey added in v0.2.2

func (document Document) PublicKey() Document

func (Document) PublicKeyPEM added in v0.2.2

func (document Document) PublicKeyPEM() string

func (Document) Rel

func (document Document) Rel() Document

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-rel Rel is expected to be a string, but this function returns a document because it may contain multiple values (rel:["canonical", "preview"])

func (*Document) SetBCC added in v0.8.1

func (document *Document) SetBCC(value ...string) bool

SetBCC sets the "bcc" property of the document

func (*Document) SetBTo added in v0.8.1

func (document *Document) SetBTo(value ...string) bool

SetBto sets the "bto" property of the document

func (*Document) SetCC added in v0.8.1

func (document *Document) SetCC(value ...string) bool

SetCC sets the "cc" property of the document

func (*Document) SetHTTPHeader added in v0.7.0

func (document *Document) SetHTTPHeader(httpHeader http.Header)

SetHTTPHeader sets the http.Header object associated with this document

func (*Document) SetProperty added in v0.7.0

func (document *Document) SetProperty(property string, value any)

SetProperty sets an individual property within this document.

func (*Document) SetString added in v0.8.1

func (document *Document) SetString(name string, value ...string) bool

SetString sets a string property on the document

func (*Document) SetTo added in v0.8.1

func (document *Document) SetTo(value ...string) bool

SetTo sets the "to" property of the document

func (*Document) SetValue added in v0.4.2

func (document *Document) SetValue(value property.Value)

SetValue sets the value of this document to a new value.

func (Document) Slice added in v0.4.2

func (document Document) Slice() []any

Array returns the array value of the current object

func (Document) SliceOfDocuments added in v0.4.2

func (document Document) SliceOfDocuments() sliceof.Object[Document]

SliceOfDocuments transforms the current object into a slice of separate Document objects, one for each value in the current document array.

func (Document) Statistics added in v0.8.1

func (document Document) Statistics() Statistics

Statistics returns counts for various interactions: Announces, Replies, Likes, and Dislikes

func (Document) Streams added in v0.8.0

func (document Document) Streams() Document

func (Document) String added in v0.4.0

func (document Document) String() string

String returns the current object as a pure string (no HTML). This value is filtered by blueMonday, so it is safe to use in HTML.

func (Document) Summary

func (document Document) Summary() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary TODO: Implement Language Maps

func (Document) Tail

func (document Document) Tail() Document

Tail returns all records after the first in a slice. For all other document types, it returns a nil document.

func (Document) Time added in v0.4.0

func (document Document) Time() time.Time

Time returns the current object as a time value

func (Document) URLOrID added in v0.9.0

func (document Document) URLOrID() string

URLOrID returns the URL of the document, if it exists, otherwise it returns the ID.

func (*Document) UnmarshalJSON

func (document *Document) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaller interface, and provides a custom un-marshalling from JSON -- essentially just aiming the unmashaller at the Document's value

func (Document) UnwrapActivity added in v0.8.0

func (document Document) UnwrapActivity() Document

If this document is an activity (create, update, delete, etc), then this method returns the activity's Object. Otherwise, it returns the document itself.

func (Document) Username added in v0.9.0

func (document Document) Username() string

func (Document) UsernameOrID added in v0.9.0

func (document Document) UsernameOrID() string

func (Document) Value

func (document Document) Value() any

Value returns the generic data stored in this Document

func (*Document) WithOptions added in v0.4.2

func (document *Document) WithOptions(options ...DocumentOption)

type DocumentOption added in v0.7.0

type DocumentOption func(*Document)

func WithClient added in v0.4.0

func WithClient(client Client) DocumentOption

WithClient option sets the HTTP client that can load remote documents if necessary

func WithHTTPHeader added in v0.7.0

func WithHTTPHeader(httpHeader http.Header) DocumentOption

WithHTTPHeader attaches an HTTP header to the document

func WithStats added in v0.8.1

func WithStats(statistics Statistics) DocumentOption

WithStats attaches statistics to the document

type Image added in v0.4.2

type Image struct {
	// contains filtered or unexported fields
}

https://www.w3.org/ns/activitystreams#Image

func NewImage added in v0.4.2

func NewImage(value any) Image

NewImage creates a new Image object from a JSON-LD value (string, map[string]any, or []any)

func (Image) AspectRatio added in v0.8.1

func (image Image) AspectRatio() float64

AspectRatio calculates the aspect ratio of the image (width / height) If height and width are not available, then 0 is returned

func (Image) HasDimensions added in v0.4.2

func (image Image) HasDimensions() bool

HasDimensions returns TRUE if this image has both a height and width defined

func (Image) HasHeight added in v0.4.2

func (image Image) HasHeight() bool

HasHeight returns TRUE if this image has a height defined

func (Image) HasWidth added in v0.4.2

func (image Image) HasWidth() bool

HasWidth returns TRUE if this image has a width defined

func (Image) Height added in v0.4.2

func (image Image) Height() int

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height

func (Image) Href added in v0.9.0

func (image Image) Href() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-href Note: This method searches both the "href" and "url" properties in maps.

func (Image) IsNil added in v0.4.2

func (image Image) IsNil() bool

IsNil returns TRUE if this image is nil (having no URL)

func (Image) MediaType added in v0.4.2

func (image Image) MediaType() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype

func (Image) NotNil added in v0.4.2

func (image Image) NotNil() bool

NotNil returns TRUE if this image has a URL

func (Image) Summary added in v0.4.2

func (image Image) Summary() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary

func (Image) URL added in v0.4.2

func (image Image) URL() string

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-href Note: URL is an alias for Href, which is the proper name to use

func (Image) Width added in v0.4.2

func (image Image) Width() int

https://www.w3.org/TR/activitystreams-vocabulary/#dfn-width

type OrderedCollection

type OrderedCollection struct {
	Context      Context `json:"@context,omitempty"     bson:"@context,omitempty"`
	ID           string  `json:"id,omitempty"           bson:"id,omitempty"`
	Type         string  `json:"type,omitempty"         bson:"type,omitempty"`
	Summary      string  `json:"summary,omitempty"      bson:"summary,omitempty"`      // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems   int     `json:"totalItems,omitempty"   bson:"totalItems,omitempty"`   // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	OrderedItems []any   `json:"orderedItems,omitempty" bson:"orderedItems,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered.
	Current      string  `json:"current,omitempty"      bson:"current,omitempty"`      // In a paged Collection, indicates the page that contains the most recently updated member items.
	First        string  `json:"first,omitempty"        bson:"first,omitempty"`        // In a paged Collection, indicates the furthest preceding page of items in the collection.
	Last         string  `json:"last,omitempty"         bson:"last,omitempty"`         // In a paged Collection, indicates the furthest proceeding page of the collection.
}

OrderedCollection is a subtype of Collection in which members of the logical collection are assumed to always be strictly ordered. https://www.w3.org/ns/activitystreams#OrderedCollection

func NewOrderedCollection added in v0.3.0

func NewOrderedCollection() OrderedCollection

func (*OrderedCollection) UnmarshalJSON

func (c *OrderedCollection) UnmarshalJSON(data []byte) error

func (*OrderedCollection) UnmarshalMap

func (c *OrderedCollection) UnmarshalMap(data mapof.Any) error

type OrderedCollectionPage

type OrderedCollectionPage struct {
	Context      Context `json:"@context,omitempty"     bson:"context,omitempty"`
	Type         string  `json:"type,omitempty"         bson:"type,omitempty"`
	Summary      string  `json:"summary,omitempty"      bson:"summary,omitempty"`      // A natural language summarization of the object encoded as HTML. Multiple language tagged summaries may be provided.
	TotalItems   int     `json:"totalItems,omitempty"   bson:"totalItems,omitempty"`   // A non-negative integer specifying the total number of objects contained by the logical view of the collection. This number might not reflect the actual number of items serialized within the Collection object instance.
	Current      string  `json:"current,omitempty"      bson:"current,omitempty"`      // In a paged Collection, indicates the page that contains the most recently updated member items.
	First        string  `json:"first,omitempty"        bson:"first,omitempty"`        // In a paged Collection, indicates the furthest preceding page of items in the collection.
	Last         string  `json:"last,omitempty"         bson:"last,omitempty"`         // In a paged Collection, indicates the furthest proceeding page of the collection.
	StartIndex   int     `json:"startIndex,omitempty"   bson:"startIndex,omitempty"`   // A non-negative integer value identifying the relative position within the logical view of a strictly ordered collection.
	PartOf       string  `json:"partOf,omitempty"       bson:"partOf,omitempty"`       // dentifies the Collection to which a CollectionPage objects items belong.
	Prev         string  `json:"prev,omitempty"         bson:"prev,omitempty"`         // In a paged Collection, identifies the previous page of items.
	Next         string  `json:"next,omitempty"         bson:"next,omitempty"`         // In a paged Collection, indicates the next page of items.
	OrderedItems []any   `json:"orderedItems,omitempty" bson:"orderedItems,omitempty"` // Identifies the items contained in a collection. The items might be ordered or unordered.
}

OrderedCollectionPage is used to represent ordered subsets of items from an OrderedCollection. Refer to the Activity Streams 2.0 Core for a complete description of the OrderedCollectionPage object. https://www.w3.org/ns/activitystreams#OrderedCollectionPage

func NewOrderedCollectionPage added in v0.3.0

func NewOrderedCollectionPage() OrderedCollectionPage

func (*OrderedCollectionPage) UnmarshalJSON

func (c *OrderedCollectionPage) UnmarshalJSON(data []byte) error

func (*OrderedCollectionPage) UnmarshalMap

func (c *OrderedCollectionPage) UnmarshalMap(data mapof.Any) error

type Statistics added in v0.8.1

type Statistics struct {
	Replies   int64 `json:"replies"   bson:"replies,omitempty"`   // Replies is the number of replies to this document
	Likes     int64 `json:"likes"     bson:"likes,omitempty"`     // Likes is the number of times this document has been liked
	Dislikes  int64 `json:"dislikes"  bson:"dislikes,omitempty"`  // Dislikes is the number of times this document has been disliked
	Announces int64 `json:"announces" bson:"announces,omitempty"` // Announces is the number of times this document has been announced / reposted
}

Statistics contains totals for various interactions with a document

func NewStatistics added in v0.8.1

func NewStatistics() Statistics

NewStatistics returns a fully initialized Statistics object

func (Statistics) HasAnnounces added in v0.8.2

func (stats Statistics) HasAnnounces() bool

func (Statistics) HasDislikes added in v0.8.2

func (stats Statistics) HasDislikes() bool

func (Statistics) HasLikes added in v0.8.2

func (stats Statistics) HasLikes() bool

func (Statistics) HasReplies added in v0.8.2

func (stats Statistics) HasReplies() bool

func (Statistics) IsEmpty added in v0.8.1

func (stats Statistics) IsEmpty() bool

func (Statistics) NotEmpty added in v0.8.1

func (stats Statistics) NotEmpty() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL