Documentation
¶
Index ¶
- Constants
- func DocumentCategory(documentType string) string
- func IsActivity(documentType string) bool
- func IsActor(documentType string) bool
- func IsCollection(documentType string) bool
- func IsObject(documentType string) bool
- func UnmarshalItems(data any) ([]any, bool)
- type Client
- type Collection
- type CollectionHeader
- type CollectionPage
- type Context
- func (c *Context) Add(vocabulary string) *ContextEntry
- func (c Context) Head() *ContextEntry
- func (c Context) IsEmpty() bool
- func (c Context) IsEmptyTail() bool
- func (c Context) Length() int
- func (c Context) MarshalJSON() ([]byte, error)
- func (c Context) Tail() Context
- func (c *Context) UnmarshalJSON(data []byte) error
- type ContextEntry
- func (entry ContextEntry) HasExtensions() bool
- func (entry ContextEntry) IsLanguageDefined() bool
- func (entry ContextEntry) IsVocabularyOnly() bool
- func (entry ContextEntry) MarshalJSON() ([]byte, error)
- func (entry *ContextEntry) WithExtension(key string, value string) *ContextEntry
- func (entry *ContextEntry) WithLanguage(language string) *ContextEntry
- type DefaultClient
- type Document
- func (document Document) Accuracy() float64
- func (document Document) Actor() Document
- func (document Document) Altitude() float64
- func (document Document) AnyOf() Document
- func (document *Document) Append(name string, value any) bool
- func (document Document) AppendBCC(value string) bool
- func (document Document) AppendBTo(value string) bool
- func (document Document) AppendCC(value string) bool
- func (document *Document) AppendString(name string, value string) bool
- func (document Document) AppendTo(value string) bool
- func (document Document) AspectRatio() string
- func (document Document) AtContext() Document
- func (document Document) Attachment() Document
- func (document Document) AttributedTo() Document
- func (document Document) Audience() Document
- func (document Document) BCC() Document
- func (document Document) BTo() Document
- func (document Document) Blocked() Document
- func (document Document) Bool() bool
- func (document Document) CC() Document
- func (document Document) Channel() <-chan Document
- func (document *Document) Client() Client
- func (document Document) Clone() Document
- func (document Document) Closed() Document
- func (document Document) Content() string
- func (document Document) Context() string
- func (document Document) Current() Document
- func (document Document) Deleted() time.Time
- func (document Document) Describes() Document
- func (document Document) DocumentCategory() string
- func (document Document) Duration() string
- func (document Document) Encoding() string
- func (document Document) EndTime() time.Time
- func (document Document) Endpoints() Document
- func (document Document) Featured() Document
- func (document Document) First() Document
- func (document Document) FirstImageAttachment() Image
- func (document Document) Float() float64
- func (document Document) Followers() Document
- func (document Document) Following() Document
- func (document Document) FormerType() string
- func (document Document) Generator() Document
- func (document Document) Get(key string) Document
- func (document Document) HTMLString() string
- func (document Document) HTTPHeader() http.Header
- func (document Document) HasContent() bool
- func (document Document) HasDimensions() bool
- func (document Document) HasIcon() bool
- func (document Document) HasImage() bool
- func (document Document) HasSummary() bool
- func (document Document) Head() Document
- func (document Document) Height() int
- func (document Document) Href() string
- func (document Document) Hreflang() string
- func (document Document) ID() string
- func (document Document) Icon() Image
- func (document Document) IconOrImage() Image
- func (document Document) Image() Image
- func (document Document) ImageOrIcon() Image
- func (document Document) InReplyTo() Document
- func (document Document) Inbox() Document
- func (document Document) Instrument() Document
- func (document Document) Int() int
- func (document Document) IsActivity() bool
- func (document Document) IsActor() bool
- func (document Document) IsBool() bool
- func (document Document) IsCollection() bool
- func (document Document) IsEmpty() bool
- func (document Document) IsEmptyTail() bool
- func (document Document) IsFloat() bool
- func (document Document) IsInt() bool
- func (document Document) IsInt64() bool
- func (document Document) IsMap() bool
- func (document Document) IsNil() bool
- func (document Document) IsObject() bool
- func (document Document) IsSlice() bool
- func (document Document) IsString() bool
- func (document Document) Items() Document
- func (document Document) Last() Document
- func (document Document) Latitude() float64
- func (document Document) Len() int
- func (document Document) Liked() Document
- func (document Document) Likes() Document
- func (document Document) Load(options ...any) (Document, error)
- func (document Document) LoadLink(options ...any) Document
- func (document Document) Location() Document
- func (document Document) Longitude() float64
- func (document Document) MLSKeyPackages() Document
- func (document Document) Map(options ...string) mapof.Any
- func (document Document) MapKeys() sliceof.String
- func (document Document) MarshalJSON() ([]byte, error)
- func (document Document) MediaType() string
- func (document Document) MustLoad(options ...any) Document
- func (document Document) Name() string
- func (document Document) Next() Document
- func (document Document) NotActivity() bool
- func (document Document) NotActor() bool
- func (document Document) NotCollection() bool
- func (document Document) NotEmpty() bool
- func (document Document) NotNil() bool
- func (document Document) NotObject() bool
- func (document Document) Object() Document
- func (document Document) OneOf() Document
- func (document Document) Origin() Document
- func (document Document) Outbox() Document
- func (document Document) PartOf() Document
- func (document Document) PreferredInbox() string
- func (document Document) PreferredUsername() string
- func (document Document) Prev() Document
- func (document Document) Preview() Document
- func (document Document) PublicKey() Document
- func (document Document) PublicKeyPEM() string
- func (document Document) Published() time.Time
- func (document Document) Radius() float64
- func (document Document) Range() iter.Seq[Document]
- func (document Document) RangeAddressees() iter.Seq[string]
- func (document Document) RangeIDs() iter.Seq[string]
- func (document Document) RangeInReplyTo() iter.Seq[string]
- func (document Document) RangeMentions() iter.Seq[string]
- func (document Document) RangeWithIndex() iter.Seq2[int, Document]
- func (document Document) Recipients() sliceof.String
- func (document Document) Rel() Document
- func (document Document) Relationship() string
- func (document Document) Replies() Document
- func (document Document) Result() Document
- func (document Document) SetBCC(value ...string) bool
- func (document Document) SetBTo(value ...string) bool
- func (document Document) SetCC(value ...string) bool
- func (document *Document) SetHTTPHeader(httpHeader http.Header)
- func (document Document) SetID(value string) bool
- func (document Document) SetProperty(property string, value any)
- func (document *Document) SetString(name string, value ...string) bool
- func (document Document) SetTo(value ...string) bool
- func (document *Document) SetValue(value property.Value)
- func (document Document) SharedInbox() string
- func (document Document) Shares() Document
- func (document Document) Slice() sliceof.Any
- func (document Document) SliceOfDocuments() sliceof.Object[Document]
- func (document Document) SliceOfString() sliceof.String
- func (document Document) StartIndex() int
- func (document Document) StartTime() time.Time
- func (document Document) Streams() Document
- func (document Document) String() string
- func (document Document) Subject() Document
- func (document Document) Summary() string
- func (document Document) SummaryWithTagLinks() string
- func (document Document) Tag() Document
- func (document Document) Tail() Document
- func (document Document) Target() Document
- func (document Document) Time() time.Time
- func (document Document) To() Document
- func (document Document) TotalItems() int
- func (document Document) Type() string
- func (document Document) Types() []string
- func (document Document) URL() string
- func (document Document) URLOrID() string
- func (document Document) Units() string
- func (document *Document) UnmarshalJSON(bytes []byte) error
- func (document Document) UnwrapActivity() Document
- func (document Document) Updated() time.Time
- func (document Document) Username() string
- func (document Document) UsernameOrID() string
- func (document Document) Value() any
- func (document Document) Width() int
- func (document *Document) WithOptions(options ...DocumentOption)
- type DocumentOption
- type Image
- func (image Image) AspectRatio() float64
- func (image Image) HasDimensions() bool
- func (image Image) HasHeight() bool
- func (image Image) HasWidth() bool
- func (image Image) Height() int
- func (image Image) Href() string
- func (image Image) IsNil() bool
- func (image Image) MediaType() string
- func (image Image) NotNil() bool
- func (image Image) Summary() string
- func (image Image) URL() string
- func (image Image) Width() int
- type Metadata
- func (metadata Metadata) HasAnnounces() bool
- func (metadata Metadata) HasDislikes() bool
- func (metadata Metadata) HasLikes() bool
- func (metadata Metadata) HasRelationship() bool
- func (metadata Metadata) HasReplies() bool
- func (metadata Metadata) IsActor() bool
- func (metadata Metadata) IsCollection() bool
- func (metadata Metadata) IsObject() bool
- func (metadata *Metadata) SetRelationCount(relationType string, count int64) bool
- type OrderedCollection
- type OrderedCollectionPage
- type Uniquer
Constants ¶
const OptionStripContext = "STRIP_CONTEXT"
OptionStripContext instructs the Document.Map() method to remove the "@context" property from its ouput.
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 DocumentCategory ¶ added in v0.14.0
DocumentCategory returns the higher level category for the provided document type: [Activity, Actor, Collection, Object]
func IsActivity ¶ added in v0.14.0
func IsCollection ¶ added in v0.14.0
func UnmarshalItems ¶
Types ¶
type Client ¶ added in v0.1.19
type Client interface {
// SetRootClient is used to make a pointer to the top-level
// client. This may be needed by some stacked clients that
// make recursive calls to the Interwebs.
SetRootClient(Client)
// Load returns a Document representing the specified URI.
Load(uri string, options ...any) (Document, error)
// Save stores the Document in a local cache. (NOOP for most clients)
Save(document Document) error
// Delete removes a Document from a local cache (NOOP for most clients)
Delete(documentID string) 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.1.19
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.1.19
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 CollectionHeader ¶ added in v0.15.1
type CollectionHeader struct {
Context Context `json:"@context,omitempty" bson:"context,omitempty"` // JSON-LD context to use
ID string `json:"id,omitempty" bson:"id,omitempty"` // ID/URL of the Collection
Type string `json:"type,omitempty" bson:"type,omitempty"` // Type of the Collection ("Collection" or "OrderedCollection")
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.
First string `json:"first,omitempty" bson:"first,omitempty"` // In a paged Collection, indicates the furthest preceding page of items in the collection.
}
CollectionHeader is an opinionated format for generating/parsing the header information of a Collection. It does not include any actual items, just the `totalItems` and `first` page URL.
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 ¶ added in v0.1.19
func NewCollectionPage(pageID string) CollectionPage
func (*CollectionPage) UnmarshalJSON ¶
func (c *CollectionPage) UnmarshalJSON(data []byte) error
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 (*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) IsEmptyTail ¶
func (Context) MarshalJSON ¶
func (*Context) UnmarshalJSON ¶
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.1.19
type DefaultClient struct {
// contains filtered or unexported fields
}
DefaultClient is a default implementation of the hannibal.Client interface. It simply loads ActivityStream documents from remote servers with no caching
func (DefaultClient) Delete ¶ added in v0.14.0
func (client DefaultClient) Delete(documentID string) error
Delete is required to implement the document.Cache interface. For this client, Delete is a NOOP
func (DefaultClient) Load ¶ added in v0.1.19
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.
func (DefaultClient) Save ¶ added in v0.14.0
func (client DefaultClient) Save(document Document) error
Save is required to implement the document.Cache interface. For this client, Save is a NOOP
func (DefaultClient) SetRootClient ¶ added in v0.14.0
func (client DefaultClient) SetRootClient(rootClient Client)
SetRootClient is required to implement the hannibal.Client interface. For this client, SetRootClient is a NOOP
type Document ¶
type Document struct {
Metadata Metadata
// 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) Accuracy ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accuracy
func (Document) Altitude ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-altitude
func (Document) AppendBCC ¶ added in v0.1.19
AppendBCC appends a value to the "bcc" property of the document
func (Document) AppendBTo ¶ added in v0.1.19
AppendBTo appends a value to the "bto" property of the document
func (Document) AppendCC ¶ added in v0.1.19
AppendCC appends a value to the "cc" property of the document
func (*Document) AppendString ¶ added in v0.1.19
AppendString appends a string to a property on the document
func (Document) AppendTo ¶ added in v0.1.19
AppendTo appends a value to the "to" property of the document
func (Document) AspectRatio ¶ added in v0.1.19
AspectRatio inspects a Document's "width" and "height" properties and (if they are non-zero) returns a computed aspect ratio
func (Document) Audience ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audience
func (Document) Channel ¶ added in v0.1.19
Channel returns a channel that iterates over all of the sub-documents in the current document. deprecated: Use Range method instead of channels
func (Document) Closed ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-closed
func (Document) Content ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content
func (Document) Context ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context IMPORTANT: THIS IS NOT THE @context PROPERTY REQUIRED FOR EVERY JSON-LD DOCUMENT
func (Document) Current ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-current
func (Document) Deleted ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-deleted
func (Document) DocumentCategory ¶ added in v0.14.0
func (Document) Duration ¶
TODO: Implement Durations per https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
func (Document) EndTime ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-endtime
func (Document) FirstImageAttachment ¶ added in v0.12.1
FirstImageAttachment scans all attachments and returns the first one with a media type that begins with "image/"
func (Document) HTMLString ¶ added in v0.1.19
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.1.19
HTTPHeader returns the http.Header object associated with this document
func (Document) HasContent ¶ added in v0.1.19
HasContent returns TRUE if this document has a valid Content property
func (Document) HasDimensions ¶ added in v0.1.19
func (Document) HasIcon ¶ added in v0.13.3
HasIcon returns TRUE if this document has a valid Icon property
func (Document) HasImage ¶ added in v0.1.19
HasImage returns TRUE if this document has a valid Image property
func (Document) HasSummary ¶ added in v0.1.19
HasSummary returns TRUE if this document has a valid Summary property
func (Document) Head ¶
Head returns the first object in a slice. For all other document types, it returns the current document.
func (Document) Height ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height
func (Document) Hreflang ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-hreflang
func (Document) IconOrImage ¶ added in v0.1.19
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.1.19
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) IsActivity ¶ added in v0.1.19
IsActivity returns TRUE if this document represents an Activity
func (Document) IsActor ¶ added in v0.1.19
IsActor returns TRUE if this document represents an Actor
func (Document) IsCollection ¶ added in v0.1.19
IsCollection returns TRUE if this document represents a Collection or CollectionPage
func (Document) IsEmptyTail ¶
IsEmptyTail return TRUE there are no array items after the current value
func (Document) IsObject ¶
IsObject returns TRUE if this document represents an Object type (Article, Note, etc)
func (Document) Items ¶
Items returns the items collection for this Document. If the document contains an "orderedItems" collection, then it is returned instead.
func (Document) Latitude ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-latitude
func (Document) Len ¶ added in v0.1.19
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) LoadLink ¶ added in v0.1.19
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) Location ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-location
func (Document) MLSKeyPackages ¶ added in v0.15.1
func (Document) MarshalJSON ¶
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.1.19
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.1.19
NotActivity returns TRUE if this document does NOT represent an Activity
func (Document) NotActor ¶ added in v0.1.19
NotActor returns TRUE if this document does NOT represent an Actor
func (Document) NotCollection ¶ added in v0.1.19
NotCollection returns TRUE if the document does NOT represent a Collection or CollectionPage
func (Document) NotEmpty ¶ added in v0.13.3
NotEmpty returns TRUE if the document has at least one item in it.
func (Document) NotObject ¶ added in v0.1.19
NotObject returns TRUE if this document does NOT represent an Object type (Article, Note, etc)
func (Document) Object ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object
func (Document) Origin ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-origin
func (Document) PartOf ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-partof
func (Document) PreferredInbox ¶ added in v0.15.0
PreferredInbox returns an actor's Shared Inbox (if available) otherwise the actor's regular Inbox
func (Document) PreferredUsername ¶ added in v0.1.19
func (Document) Preview ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-preview
func (Document) PublicKeyPEM ¶ added in v0.1.19
func (Document) Radius ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-radius
func (Document) RangeAddressees ¶ added in v0.13.0
func (Document) RangeIDs ¶ added in v0.13.0
RangeIDs returns an iterator that yields the IDs of each element of a Document. If the Document is empty, it yields no values. If the Document is a single object, then it yields the ID of that object. If the Document is a list, then it yields the IDs of each object in the list
func (Document) RangeInReplyTo ¶ added in v0.13.0
func (Document) RangeMentions ¶ added in v0.13.0
func (Document) RangeWithIndex ¶ added in v0.13.3
func (Document) Recipients ¶ added in v0.15.0
Recipients retrieves all recipients of an activity, i.e. actors identified in the to, cc, bcc, and bto fields
func (Document) Rel ¶
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) Replies ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-replies
func (Document) Result ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-result
func (*Document) SetHTTPHeader ¶ added in v0.1.19
SetHTTPHeader sets the http.Header object associated with this document
func (Document) SetProperty ¶ added in v0.1.19
SetProperty sets an individual property within this document.
func (*Document) SetValue ¶ added in v0.1.19
SetValue sets the value of this document to a new value.
func (Document) SharedInbox ¶ added in v0.15.0
func (Document) SliceOfDocuments ¶ added in v0.1.19
SliceOfDocuments transforms the current object into a slice of separate Document objects, one for each value in the current document array.
func (Document) SliceOfString ¶ added in v0.15.0
SliceOfString transforms the current object into a slice of strings by extracting the ID from each sub-document in the current document array.
func (Document) String ¶ added in v0.1.19
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) Subject ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-subject
func (Document) Summary ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary TODO: Implement Language Maps
func (Document) SummaryWithTagLinks ¶ added in v0.13.3
SummaryWithTagLinks
func (Document) Tail ¶
Tail returns all records after the first in a slice. For all other document types, it returns a nil document.
func (Document) Target ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-target
func (Document) Types ¶ added in v0.1.19
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 ¶ added in v0.1.19
URLOrID returns the URL of the document, if it exists, otherwise it returns the ID.
func (*Document) UnmarshalJSON ¶
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.1.19
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) Updated ¶
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-updated
func (Document) Username ¶ added in v0.1.19
Alias for https://www.w3.org/TR/activitypub/#preferredUsername
func (Document) UsernameOrID ¶ added in v0.1.19
UsernameOrID returns the username of the document, if it exists, or the ID of the document if it does not.
func (*Document) WithOptions ¶ added in v0.1.19
func (document *Document) WithOptions(options ...DocumentOption)
type DocumentOption ¶ added in v0.1.19
type DocumentOption func(*Document)
func WithClient ¶ added in v0.1.19
func WithClient(client Client) DocumentOption
WithClient option sets the HTTP client that can load remote documents if necessary
func WithHTTPHeader ¶ added in v0.1.19
func WithHTTPHeader(httpHeader http.Header) DocumentOption
WithHTTPHeader attaches an HTTP header to the document
func WithMetadata ¶ added in v0.14.0
func WithMetadata(metadata Metadata) DocumentOption
WithMetadata attaches metadata to the document
type Image ¶ added in v0.1.19
type Image struct {
// contains filtered or unexported fields
}
https://www.w3.org/ns/activitystreams#Image
func NewImage ¶ added in v0.1.19
NewImage creates a new Image object from a JSON-LD value (string, map[string]any, or []any)
func (Image) AspectRatio ¶ added in v0.1.19
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.1.19
HasDimensions returns TRUE if this image has both a height and width defined
func (Image) Height ¶ added in v0.1.19
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-height
func (Image) Href ¶ added in v0.1.19
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-href Note: This method searches both the "href" and "url" properties in maps.
func (Image) MediaType ¶ added in v0.1.19
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype
func (Image) Summary ¶ added in v0.1.19
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary
func (Image) URL ¶ added in v0.1.19
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-href Note: URL is an alias for Href, which is the proper name to use
type Metadata ¶ added in v0.14.0
type Metadata struct {
HashedID string `bson:"hashedId,omitempty"` // HashedID is a unique identifier for this document, used to prevent duplicate records
DocumentCategory string `bson:"documentCategory,omitempty"` // High-level category of the document [Activity, Actor, Object, Collection]
RelationType string `bson:"relationType,omitempty"` // If this document is related to another document, this contains the type of relation [Reply, Announce, Like, Dislike]
RelationHref string `bson:"relationHref,omitempty"` // If this document is related to another document, this contains the URL of the related document
Replies int64 `bson:"replies,omitempty"` // Replies is the number of replies to this document
Announces int64 `bson:"announces,omitempty"` // Announces is the number of times this document has been announced / reposted
Likes int64 `bson:"likes,omitempty"` // Likes is the number of times this document has been liked
Dislikes int64 `bson:"dislikes,omitempty"` // Dislikes is the number of times this document has been disliked
}
Metadata contains structured metadata for each document, which is useful for collecting/querying records in a database
func NewMetadata ¶ added in v0.14.0
func NewMetadata() Metadata
NewMetadata returns a fully initialized Metadata object
func (Metadata) HasAnnounces ¶ added in v0.14.0
HasAnnounces returns TRUE if this document has one or more Announces
func (Metadata) HasDislikes ¶ added in v0.14.0
HasDislikes returns TRUE if this document has one or more Dislikes
func (Metadata) HasLikes ¶ added in v0.14.0
HasLikes returns TRUE if this document has one or more Likes
func (Metadata) HasRelationship ¶ added in v0.14.0
HasRelationship returns TRUE if this document has a relationship
func (Metadata) HasReplies ¶ added in v0.14.0
HasReplies returns TRUE if this document has one or more Replies
func (Metadata) IsActor ¶ added in v0.14.0
IsActor returns TRUE if this document is one of several "Actor" types [Application, Group, Organization, Person, Service]
func (Metadata) IsCollection ¶ added in v0.14.0
IsCollection returns TRUE if this document is one of several "Collection" types [Collection, CollectionPage, OrderedCollection, OrderedCollectionPage]
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.1.19
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 ¶ added in v0.1.19
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 Uniquer ¶ added in v0.13.0
type Uniquer[T comparable] struct { // contains filtered or unexported fields }
Uniquer is a utility class that helps to identify unique values
func NewUniquer ¶ added in v0.13.0
func NewUniquer[T comparable]() *Uniquer[T]
NewUniquer returns a fully initialized Uniquer object
func (*Uniquer[T]) IsDuplicate ¶ added in v0.13.0
IsDuplicate returns TRUE if the value has been seen before.
Source Files
¶
- client.go
- client_http.go
- collection.go
- collectionHeader.go
- collectionPage.go
- context.go
- contextEntry.go
- documentOption.go
- document_.go
- document_actor.go
- document_header.go
- document_json.go
- document_set.go
- document_special.go
- document_vocabulary.go
- image.go
- items.go
- metadata.go
- options.go
- orderedCollection.go
- orderedCollectionPage.go
- range.go
- types.go
- uniquer.go
- utils.go