Documentation ¶
Overview ¶
Package astreams implements JSON serialization/deserialization support for the ActivityStreams 2.0 vocabulary. Simply use json.Marshal/json.Unmarshal on AS 2.0 compliant objects to obtain their JSON/Go representation respectively.
Indirect object references such as a link to an outbox collection within an actor profile need to be fetched explicitly and parsed as a separate object.
Index ¶
- func ConcreteType(t ActivityStreamer) (reflectType, astreamsType string)
- type Accept
- type Activity
- type ActivityStreamer
- type Actor
- type Add
- type Announce
- type Application
- type Arrive
- type Article
- type Audio
- type Block
- type Collection
- type CollectionPage
- type Create
- type Delete
- type Dislike
- type Document
- type Endpoint
- type EndpointsOrString
- type Event
- type Flag
- type Follow
- type Group
- type Hashtag
- type Icon
- type Icons
- type Ignore
- type Image
- type IntransitiveActivity
- type Invite
- type Join
- type Leave
- type Like
- type Link
- type Listen
- type Location
- type Mention
- type Move
- type Note
- type Object
- type ObjectOrLink
- type ObjectOrLinkOrString
- type Offer
- type OrderedCollection
- type OrderedCollectionPage
- type Organization
- type Page
- type Person
- type Place
- type Profile
- type PropertyValue
- type PublicKey
- type Question
- type Read
- type Reject
- type Relationship
- type Remove
- type Service
- type StringWithCollection
- type StringWithOrderedCollection
- type TentativeAccept
- type TentativeReject
- type Tombstone
- type Travel
- type Undo
- type Update
- type Video
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcreteType ¶
func ConcreteType(t ActivityStreamer) (reflectType, astreamsType string)
ConcreteType returns both, the type name obtained using reflection, as well as the Type property of the Object/Link. The object's own Type property is going to be more specific, so use that where useful.
Types ¶
type Activity ¶
type Activity struct { Object Actor *ObjectOrLinkOrString `json:"actor,omitempty"` ActivityObject *ObjectOrLinkOrString `json:"object,omitempty"` // the 'object' property of Activity Target *ObjectOrLinkOrString `json:"target,omitempty"` Result *ObjectOrLinkOrString `json:"result,omitempty"` Origin *ObjectOrLinkOrString `json:"origin,omitempty"` Instrument *ObjectOrLinkOrString `json:"instrument,omitempty"` }
type ActivityStreamer ¶ added in v0.5.0
type ActivityStreamer interface { IsObject() bool IsLink() bool GetObject() *Object GetLink() *Link }
ActivityStreamer can be either a (sub)type of an 'Object' or 'Link'
type Actor ¶
type Actor struct { Object PublicKey *PublicKey `json:"publicKey,omitempty"` Inbox *StringWithOrderedCollection `json:"inbox,omitempty"` Outbox *StringWithOrderedCollection `json:"outbox,omitempty"` Followers *StringWithOrderedCollection `json:"followers,omitempty"` Following *StringWithOrderedCollection `json:"following,omitempty"` Liked *StringWithOrderedCollection `json:"liked,omitempty"` Streams *ObjectOrLinkOrString `json:"streams,omitempty"` PreferredUsername string `json:"preferredUsername,omitempty"` ManuallyApprovesFollowers bool `json:"manuallyApprovesFollowers,omitempty"` EndpointsOrURI *EndpointsOrString `json:"endpoints,omitempty"` }
type Arrive ¶
type Arrive = IntransitiveActivity
type Collection ¶
type Collection struct { Object TotalItems int `json:"totalItems,omitempty"` Current *ObjectOrLinkOrString `json:"current,omitempty"` First *ObjectOrLinkOrString `json:"first,omitempty"` Last *ObjectOrLinkOrString `json:"last,omitempty"` Items ObjectOrLink `json:"items,omitempty"` }
Collection is provided for spec compliance, prefer OrderedCollection
type CollectionPage ¶
type CollectionPage struct { Object TotalItems int `json:"totalItems,omitempty"` Current *ObjectOrLinkOrString `json:"current,omitempty"` First *ObjectOrLinkOrString `json:"first,omitempty"` Last *ObjectOrLinkOrString `json:"last,omitempty"` PartOf *ObjectOrLinkOrString `json:"partOf,omitempty"` Next *ObjectOrLinkOrString `json:"next,omitempty"` Prev *ObjectOrLinkOrString `json:"prev,omitempty"` Items ObjectOrLink `json:"items,omitempty"` }
CollectionPage is provided for spec compliance, prefer OrderedCollectionPage
type Endpoint ¶
type Endpoint struct { ProxyUrl string `json:"proxyUrl,omitempty"` OauthAuthorizationEndpoint string `json:"oauthAuthorizationEndpoint,omitempty"` OauthTokenEndpoint string `json:"oauthTokenEndpoint,omitempty"` ProvideClientKey string `json:"provideClientKey,omitempty"` SignClientKey string `json:"signClientKey,omitempty"` }
type EndpointsOrString ¶ added in v0.3.0
func (*EndpointsOrString) MarshalJSON ¶ added in v0.3.0
func (enp *EndpointsOrString) MarshalJSON() ([]byte, error)
func (*EndpointsOrString) String ¶ added in v0.3.0
func (enp *EndpointsOrString) String() string
Implements https://golang.org/pkg/fmt/#Stringer
func (*EndpointsOrString) UnmarshalJSON ¶ added in v0.3.0
func (enp *EndpointsOrString) UnmarshalJSON(data []byte) error
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type Icons ¶
Icons is a type representing the possible ActivityPub icon values
func (*Icons) MarshalJSON ¶
func (*Icons) String ¶
Implements https://golang.org/pkg/fmt/#Stringer
func (*Icons) UnmarshalJSON ¶
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type IntransitiveActivity ¶
type IntransitiveActivity struct { Object Actor *ObjectOrLinkOrString `json:"actor,omitempty"` Target *ObjectOrLinkOrString `json:"target,omitempty"` Result *ObjectOrLinkOrString `json:"result,omitempty"` Origin *ObjectOrLinkOrString `json:"origin,omitempty"` Instrument *ObjectOrLinkOrString `json:"instrument,omitempty"` }
type Link ¶
type Link struct { ASContext *ObjectOrLinkOrString `json:"@context,omitempty"` ASLanguage string `json:"@language,omitempty"` Type string `json:"type"` Href string `json:"href,omitempty"` Hreflang string `json:"hreflang,omitempty"` Rel []string `json:"rel,omitempty"` MediaType string `json:"mediaType,omitempty"` Height int `json:"height,omitempty"` Width int `json:"width,omitempty"` Name string `json:"name,omitempty"` NameMap map[string]string `json:"nameMap,omitempty"` Value string `json:"value,omitempty"` Preview *ObjectOrLinkOrString `json:"preview,omitempty"` Published *time.Time `json:"published,omitempty"` }
Link represents the base ActivityStreams Link and all of its properties Other Link types extend it
type Location ¶
type Location struct { Object Longitude float32 `json:"longitude,omitempty"` Latitude float32 `json:"latitude,omitempty"` Altitude int `json:"altitude,omitempty"` Units string `json:"units,omitempty"` }
func (*Location) String ¶
Implements https://golang.org/pkg/fmt/#Stringer
type Object ¶
type Object struct { ASContext *ObjectOrLinkOrString `json:"@context,omitempty"` ASLanguage string `json:"@language,omitempty"` Schema string `json:"schema,omitempty"` Type string `json:"type,omitempty"` AtType string `json:"@type,omitempty"` Summary string `json:"summary,omitempty"` SummaryMap map[string]string `json:"summaryMap,omitempty"` ID string `json:"id,omitempty"` AtID string `json:"@id,omitempty"` Name string `json:"name,omitempty"` NameMap map[string]string `json:"nameMap,omitempty"` AlsoKnownAs *ObjectOrLinkOrString `json:"alsoKnownAs,omitempty"` MovedTo *ObjectOrLinkOrString `json:"movedTo,omitempty"` Attachment *ObjectOrLinkOrString `json:"attachment,omitempty"` AttributedTo *ObjectOrLinkOrString `json:"attributedTo,omitempty"` Audience *ObjectOrLinkOrString `json:"audience,omitempty"` Content string `json:"content,omitempty"` // needs to be parsed safely ie by https://golang.org/pkg/html/template ContentMap map[string]string `json:"contentMap,omitempty"` Source *ObjectOrLinkOrString `json:"source,omitempty"` Context *ObjectOrLinkOrString `json:"context,omitempty"` StartTime *time.Time `json:"startTime,omitempty"` EndTime *time.Time `json:"endTime,omitempty"` Generator *ObjectOrLinkOrString `json:"generator,omitempty"` Featured *ObjectOrLinkOrString `json:"featured,omitempty"` Likes *ObjectOrLinkOrString `json:"likes,omitempty"` Icon *ObjectOrLinkOrString `json:"icon,omitempty"` Image *ObjectOrLinkOrString `json:"image,omitempty"` InReplyTo *ObjectOrLinkOrString `json:"inReplyTo,omitempty"` Location *ObjectOrLinkOrString `json:"location,omitempty"` Preview *ObjectOrLinkOrString `json:"preview,omitempty"` Published *time.Time `json:"published,omitempty"` Replies *OrderedCollection `json:"replies,omitempty"` Tag *ObjectOrLinkOrString `json:"tag,omitempty"` Updated *time.Time `json:"updated,omitempty"` URL *ObjectOrLinkOrString `json:"url,omitempty"` To *ObjectOrLinkOrString `json:"to,omitempty"` Bto *ObjectOrLinkOrString `json:"bto,omitempty"` Cc *ObjectOrLinkOrString `json:"cc,omitempty"` Bcc *ObjectOrLinkOrString `json:"bcc,omitempty"` MediaType string `json:"mediaType,omitempty"` Duration string `json:"duration,omitempty"` // xsd:duration }
Object represents the base ActivityStreams Object and all of its properties Most of the other types extend Object
type ObjectOrLink ¶
type ObjectOrLink []ActivityStreamer
ObjectOrLink is a wrapper type that represents any type of object or link Single objects are still presented as slices, but with a single element
func (*ObjectOrLink) MarshalJSON ¶
func (ol *ObjectOrLink) MarshalJSON() ([]byte, error)
func (*ObjectOrLink) UnmarshalJSON ¶
func (ol *ObjectOrLink) UnmarshalJSON(data []byte) error
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type ObjectOrLinkOrString ¶
type ObjectOrLinkOrString struct { URL []string Target ObjectOrLink }
ObjectOrLinkOrString is a type that can either represent simple string URL(s) or an Object/Link slice
func (*ObjectOrLinkOrString) MarshalJSON ¶
func (ols *ObjectOrLinkOrString) MarshalJSON() ([]byte, error)
func (*ObjectOrLinkOrString) String ¶
func (ols *ObjectOrLinkOrString) String() string
Implements https://golang.org/pkg/fmt/#Stringer
func (*ObjectOrLinkOrString) UnmarshalJSON ¶
func (ols *ObjectOrLinkOrString) UnmarshalJSON(data []byte) error
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type OrderedCollection ¶
type OrderedCollection struct { Object TotalItems int `json:"totalItems"` Current *ObjectOrLinkOrString `json:"current,omitempty"` First *ObjectOrLinkOrString `json:"first,omitempty"` Last *ObjectOrLinkOrString `json:"last,omitempty"` OrderedItems ObjectOrLink `json:"orderedItems"` }
OrderedCollection implements https://golang.org/pkg/sort/#Interface
func (OrderedCollection) Len ¶
func (oc OrderedCollection) Len() int
func (OrderedCollection) Less ¶
func (oc OrderedCollection) Less(i, j int) bool
func (OrderedCollection) SortByUpdated ¶
func (oc OrderedCollection) SortByUpdated()
sort OrderedCollection by Updated
func (*OrderedCollection) String ¶
func (oc *OrderedCollection) String() string
Implements https://golang.org/pkg/fmt/#Stringer
func (OrderedCollection) Swap ¶
func (oc OrderedCollection) Swap(i, j int)
type OrderedCollectionPage ¶
type OrderedCollectionPage struct { Object TotalItems int `json:"totalItems,omitempty"` Current *ObjectOrLinkOrString `json:"current,omitempty"` First *ObjectOrLinkOrString `json:"first,omitempty"` Last *ObjectOrLinkOrString `json:"last,omitempty"` PartOf *ObjectOrLinkOrString `json:"partOf,omitempty"` Next *ObjectOrLinkOrString `json:"next,omitempty"` Prev *ObjectOrLinkOrString `json:"prev,omitempty"` StartIndex uint `json:"startIndex,omitempty"` OrderedItems ObjectOrLink `json:"orderedItems,omitempty"` }
OrderedCollectionPage implements https://golang.org/pkg/sort/#Interface
func (OrderedCollectionPage) Len ¶
func (ocp OrderedCollectionPage) Len() int
func (OrderedCollectionPage) Less ¶
func (ocp OrderedCollectionPage) Less(i, j int) bool
func (OrderedCollectionPage) SortByUpdated ¶
func (ocp OrderedCollectionPage) SortByUpdated()
sort OrderedCollectionPage by Updated
func (OrderedCollectionPage) Swap ¶
func (ocp OrderedCollectionPage) Swap(i, j int)
type Organization ¶
type Organization = Actor
type Profile ¶
type Profile struct { Object Describes ObjectOrLinkOrString `json:"describes,omitempty"` }
type PropertyValue ¶
type PropertyValue = Link
type Question ¶
type Question struct { IntransitiveActivity // only OneOf or AnyOf can be set, not both OneOf *ObjectOrLinkOrString `json:"oneOf,omitempty"` AnyOf *ObjectOrLinkOrString `json:"anyOf,omitempty"` Closed *time.Time `json:"closed,omitempty"` }
type Relationship ¶
type Relationship struct { Object Subject *ObjectOrLinkOrString `json:"subject,omitempty"` Relationship string `json:"relationship,omitempty"` RelationshipObject *ObjectOrLinkOrString `json:"object"` }
type StringWithCollection ¶
type StringWithCollection struct { URL string Collection Collection }
StringWithCollection can store a string URL pointing to a Collection, which can itself be stored in the struct
func (*StringWithCollection) MarshalJSON ¶
func (sc *StringWithCollection) MarshalJSON() ([]byte, error)
func (*StringWithCollection) String ¶
func (sc *StringWithCollection) String() string
Implements https://golang.org/pkg/fmt/#Stringer
func (*StringWithCollection) UnmarshalJSON ¶
func (sc *StringWithCollection) UnmarshalJSON(data []byte) error
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type StringWithOrderedCollection ¶
type StringWithOrderedCollection struct { URL string OrdCollection OrderedCollection }
StringWithOrderedCollection can store a string URL pointing to an OrderedCollection, which can itself be stored in the struct
func (*StringWithOrderedCollection) MarshalJSON ¶
func (soc *StringWithOrderedCollection) MarshalJSON() ([]byte, error)
func (*StringWithOrderedCollection) String ¶
func (soc *StringWithOrderedCollection) String() string
Implements https://golang.org/pkg/fmt/#Stringer
func (*StringWithOrderedCollection) UnmarshalJSON ¶
func (soc *StringWithOrderedCollection) UnmarshalJSON(data []byte) error
Implements https://golang.org/pkg/encoding/json/#Unmarshaler
type TentativeAccept ¶
type TentativeAccept = Accept
type TentativeReject ¶
type TentativeReject = Reject
type Travel ¶
type Travel = IntransitiveActivity