streams

package
v0.0.0-...-b348e75 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

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 Range

func Range(document Document) iter.Seq[Document]

func UnmarshalItems

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

Types

type Client

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

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

func NewCollection(collectionID string) 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"`       // Identifies the Object or Link type. (CollectionPage, OrderedCollectionPage)
	ID         string  `json:"id,omitempty"          bson:"id,omitempty"`         // Provides the globally unique identifier for an Object or Link.
	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

func NewCollectionPage(pageID string) 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

type DefaultClient struct{}

func (DefaultClient) Load

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

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

Append appends a value to a property on the document

func (*Document) AppendBCC

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

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

func (*Document) AppendBTo

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

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

func (*Document) AppendCC

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

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

func (*Document) AppendString

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

AppendString appends a string to a property on the document

func (*Document) AppendTo

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

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

func (Document) AspectRatio

func (document Document) AspectRatio() string

func (Document) Blocked

func (document Document) Blocked() Document

http://w3id.org/fep/c648

func (Document) Bool

func (document Document) Bool() bool

Bool returns the current object as a floating-point value

func (Document) Channel

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

func (document *Document) Client() Client

Client returns the HTTP client used for this document

func (Document) Clone

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

func (document Document) Endpoints() Document

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

func (Document) FirstImageAttachment

func (document Document) FirstImageAttachment() Image

func (Document) Float

func (document Document) Float() float64

Float returns the current object as an integer value

func (Document) Followers

func (document Document) Followers() Document

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

func (Document) Following

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

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

func (document Document) HTTPHeader() http.Header

HTTPHeader returns the http.Header object associated with this document

func (Document) HasContent

func (document Document) HasContent() bool

HasContent returns TRUE if this document has a valid Content property

func (Document) HasDimensions

func (document Document) HasDimensions() bool

func (Document) HasImage

func (document Document) HasImage() bool

HasImage returns TRUE if this document has a valid Image property

func (Document) HasSummary

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

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

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

func (document Document) Inbox() Document

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

func (Document) Int

func (document Document) Int() int

Int returns the current object as an integer value

func (Document) IsActivity

func (document Document) IsActivity() bool

IsActivity returns TRUE if this document represents an Activity

func (Document) IsActor

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

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

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

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

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

func (document Document) Liked() Document

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

func (Document) Likes

func (document Document) Likes() Document

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

func (Document) Load

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

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

func (Document) MapKeys

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

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

func (document Document) NotActivity() bool

NotActivity returns TRUE if this document does NOT represent an Activity

func (Document) NotActor

func (document Document) NotActor() bool

NotActor returns TRUE if this document does NOT represent an Actor

func (Document) NotCollection

func (document Document) NotCollection() bool

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

func (Document) NotNil

func (document Document) NotNil() bool

func (Document) NotObject

func (document Document) NotObject() bool

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

func (Document) Outbox

func (document Document) Outbox() Document

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

func (Document) PreferredUsername

func (document Document) PreferredUsername() string

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

func (Document) PublicKey

func (document Document) PublicKey() Document

func (Document) PublicKeyPEM

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

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

SetBCC sets the "bcc" property of the document

func (*Document) SetBTo

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

SetBto sets the "bto" property of the document

func (*Document) SetCC

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

SetCC sets the "cc" property of the document

func (*Document) SetHTTPHeader

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

SetHTTPHeader sets the http.Header object associated with this document

func (*Document) SetProperty

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

SetProperty sets an individual property within this document.

func (*Document) SetString

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

SetString sets a string property on the document

func (*Document) SetTo

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

SetTo sets the "to" property of the document

func (*Document) SetValue

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

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

func (Document) Slice

func (document Document) Slice() []any

Array returns the array value of the current object

func (Document) SliceOfDocuments

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

func (document Document) Statistics() Statistics

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

func (Document) String

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

func (document Document) Time() time.Time

Time returns the current object as a time value

func (Document) Types

func (document Document) Types() []string

A special case of the Type() function, which returns a slice of types https://www.w3.org/TR/activitystreams-vocabulary/#dfn-type

func (Document) URLOrID

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

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

func (document Document) Username() string

Alias for https://www.w3.org/TR/activitypub/#preferredUsername

func (Document) UsernameOrID

func (document Document) UsernameOrID() string

UsernameOrID returns the username of the document, if it exists, or the ID of the document if it does not.

func (Document) Value

func (document Document) Value() any

Value returns the generic data stored in this Document

func (*Document) WithOptions

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

type DocumentOption

type DocumentOption func(*Document)

func WithClient

func WithClient(client Client) DocumentOption

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

func WithHTTPHeader

func WithHTTPHeader(httpHeader http.Header) DocumentOption

WithHTTPHeader attaches an HTTP header to the document

func WithStats

func WithStats(statistics Statistics) DocumentOption

WithStats attaches statistics to the document

type Image

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

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

func NewImage

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

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

func (image Image) HasDimensions() bool

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

func (Image) HasHeight

func (image Image) HasHeight() bool

HasHeight returns TRUE if this image has a height defined

func (Image) HasWidth

func (image Image) HasWidth() bool

HasWidth returns TRUE if this image has a width defined

func (Image) Href

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

func (image Image) IsNil() bool

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

func (Image) NotNil

func (image Image) NotNil() bool

NotNil returns TRUE if this image has a URL

func (Image) URL

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

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

func NewOrderedCollection(collectionID string) 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"`
	ID           string  `json:"id,omitempty"           bson:"id,omitempty"`           // Provides the globally unique identifier for an Object or Link.
	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

func NewOrderedCollectionPage(pageID string, partOf string) OrderedCollectionPage

func (*OrderedCollectionPage) UnmarshalJSON

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

func (*OrderedCollectionPage) UnmarshalMap

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

type Statistics

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

func NewStatistics() Statistics

NewStatistics returns a fully initialized Statistics object

func (Statistics) HasAnnounces

func (stats Statistics) HasAnnounces() bool

func (Statistics) HasDislikes

func (stats Statistics) HasDislikes() bool

func (Statistics) HasLikes

func (stats Statistics) HasLikes() bool

func (Statistics) HasReplies

func (stats Statistics) HasReplies() bool

func (Statistics) IsEmpty

func (stats Statistics) IsEmpty() bool

func (Statistics) NotEmpty

func (stats Statistics) NotEmpty() bool

Jump to

Keyboard shortcuts

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