ap

package
v0.20.3 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivityAccept          = "Accept"          // ActivityStreamsAccept https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept
	ActivityAdd             = "Add"             // ActivityStreamsAdd https://www.w3.org/TR/activitystreams-vocabulary/#dfn-add
	ActivityAnnounce        = "Announce"        // ActivityStreamsAnnounce https://www.w3.org/TR/activitystreams-vocabulary/#dfn-announce
	ActivityArrive          = "Arrive"          // ActivityStreamsArrive https://www.w3.org/TR/activitystreams-vocabulary/#dfn-arrive
	ActivityBlock           = "Block"           // ActivityStreamsBlock https://www.w3.org/TR/activitystreams-vocabulary/#dfn-block
	ActivityCreate          = "Create"          // ActivityStreamsCreate https://www.w3.org/TR/activitystreams-vocabulary/#dfn-create
	ActivityDelete          = "Delete"          // ActivityStreamsDelete https://www.w3.org/TR/activitystreams-vocabulary/#dfn-delete
	ActivityDislike         = "Dislike"         // ActivityStreamsDislike https://www.w3.org/TR/activitystreams-vocabulary/#dfn-dislike
	ActivityFlag            = "Flag"            // ActivityStreamsFlag https://www.w3.org/TR/activitystreams-vocabulary/#dfn-flag
	ActivityFollow          = "Follow"          // ActivityStreamsFollow https://www.w3.org/TR/activitystreams-vocabulary/#dfn-follow
	ActivityIgnore          = "Ignore"          // ActivityStreamsIgnore https://www.w3.org/TR/activitystreams-vocabulary/#dfn-ignore
	ActivityInvite          = "Invite"          // ActivityStreamsInvite https://www.w3.org/TR/activitystreams-vocabulary/#dfn-invite
	ActivityJoin            = "Join"            // ActivityStreamsJoin https://www.w3.org/TR/activitystreams-vocabulary/#dfn-join
	ActivityLeave           = "Leave"           // ActivityStreamsLeave https://www.w3.org/TR/activitystreams-vocabulary/#dfn-leave
	ActivityLike            = "Like"            // ActivityStreamsLike https://www.w3.org/TR/activitystreams-vocabulary/#dfn-like
	ActivityListen          = "Listen"          // ActivityStreamsListen https://www.w3.org/TR/activitystreams-vocabulary/#dfn-listen
	ActivityMove            = "Move"            // ActivityStreamsMove https://www.w3.org/TR/activitystreams-vocabulary/#dfn-move
	ActivityOffer           = "Offer"           // ActivityStreamsOffer https://www.w3.org/TR/activitystreams-vocabulary/#dfn-offer
	ActivityQuestion        = "Question"        // ActivityStreamsQuestion https://www.w3.org/TR/activitystreams-vocabulary/#dfn-question
	ActivityReject          = "Reject"          // ActivityStreamsReject https://www.w3.org/TR/activitystreams-vocabulary/#dfn-reject
	ActivityRead            = "Read"            // ActivityStreamsRead https://www.w3.org/TR/activitystreams-vocabulary/#dfn-read
	ActivityRemove          = "Remove"          // ActivityStreamsRemove https://www.w3.org/TR/activitystreams-vocabulary/#dfn-remove
	ActivityTentativeReject = "TentativeReject" // ActivityStreamsTentativeReject https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativereject
	ActivityTentativeAccept = "TentativeAccept" // ActivityStreamsTentativeAccept https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tentativeaccept
	ActivityTravel          = "Travel"          // ActivityStreamsTravel https://www.w3.org/TR/activitystreams-vocabulary/#dfn-travel
	ActivityUndo            = "Undo"            // ActivityStreamsUndo https://www.w3.org/TR/activitystreams-vocabulary/#dfn-undo
	ActivityUpdate          = "Update"          // ActivityStreamsUpdate https://www.w3.org/TR/activitystreams-vocabulary/#dfn-update
	ActivityView            = "View"            // ActivityStreamsView https://www.w3.org/TR/activitystreams-vocabulary/#dfn-view

	ActorApplication  = "Application"  // ActivityStreamsApplication https://www.w3.org/TR/activitystreams-vocabulary/#dfn-application
	ActorGroup        = "Group"        // ActivityStreamsGroup https://www.w3.org/TR/activitystreams-vocabulary/#dfn-group
	ActorOrganization = "Organization" // ActivityStreamsOrganization https://www.w3.org/TR/activitystreams-vocabulary/#dfn-organization
	ActorPerson       = "Person"       // ActivityStreamsPerson https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person
	ActorService      = "Service"      // ActivityStreamsService https://www.w3.org/TR/activitystreams-vocabulary/#dfn-service

	ObjectArticle               = "Article"               // ActivityStreamsArticle https://www.w3.org/TR/activitystreams-vocabulary/#dfn-article
	ObjectAudio                 = "Audio"                 // ActivityStreamsAudio https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audio
	ObjectDocument              = "Document"              // ActivityStreamsDocument https://www.w3.org/TR/activitystreams-vocabulary/#dfn-document
	ObjectEvent                 = "Event"                 // ActivityStreamsEvent https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event
	ObjectImage                 = "Image"                 // ActivityStreamsImage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-image
	ObjectNote                  = "Note"                  // ActivityStreamsNote https://www.w3.org/TR/activitystreams-vocabulary/#dfn-note
	ObjectPage                  = "Page"                  // ActivityStreamsPage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-page
	ObjectPlace                 = "Place"                 // ActivityStreamsPlace https://www.w3.org/TR/activitystreams-vocabulary/#dfn-place
	ObjectProfile               = "Profile"               // ActivityStreamsProfile https://www.w3.org/TR/activitystreams-vocabulary/#dfn-profile
	ObjectRelationship          = "Relationship"          // ActivityStreamsRelationship https://www.w3.org/TR/activitystreams-vocabulary/#dfn-relationship
	ObjectTombstone             = "Tombstone"             // ActivityStreamsTombstone https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tombstone
	ObjectVideo                 = "Video"                 // ActivityStreamsVideo https://www.w3.org/TR/activitystreams-vocabulary/#dfn-video
	ObjectCollection            = "Collection"            // ActivityStreamsCollection https://www.w3.org/TR/activitystreams-vocabulary/#dfn-collection
	ObjectCollectionPage        = "CollectionPage"        // ActivityStreamsCollectionPage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-collectionpage
	ObjectOrderedCollection     = "OrderedCollection"     // ActivityStreamsOrderedCollection https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollection
	ObjectOrderedCollectionPage = "OrderedCollectionPage" // ActivityStreamsOrderedCollectionPage https://www.w3.org/TR/activitystreams-vocabulary/#dfn-orderedcollectionPage

	// Hashtag is not in the AS spec per se, but it tends to get used
	// as though 'Hashtag' is a named type under the Tag property.
	//
	// See https://www.w3.org/TR/activitystreams-vocabulary/#microsyntaxes
	// and https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag
	TagHashtag = "Hashtag"

	// Not in the AS spec, just used internally to indicate
	// that we don't *yet* know what type of Object something is.
	ObjectUnknown = "Unknown"

	ActivityLikeRequest         = "LikeRequest"
	ActivityReplyRequest        = "ReplyRequest"
	ActivityAnnounceRequest     = "AnnounceRequest"
	ObjectLikeAuthorization     = "LikeAuthorization"
	ObjectReplyAuthorization    = "ReplyAuthorization"
	ObjectAnnounceAuthorization = "AnnounceAuthorization"

	ObjectAlbum = "Album"
)

https://www.w3.org/TR/activitystreams-vocabulary

Variables

This section is empty.

Functions

func AppendActorIRIs

func AppendActorIRIs(with WithActor, actor ...*url.URL)

AppendActorIRIs appends the given IRIs to the Actor property of 'with'.

func AppendAttributedTo

func AppendAttributedTo(with WithAttributedTo, attribTo ...*url.URL)

AppendAttributedTo appends the given IRIs to the AttributedTo property of 'with'.

func AppendBcc

func AppendBcc(with WithBcc, bcc ...*url.URL)

AppendBcc appends the given IRIs to the Bcc property of 'with'.

func AppendCc

func AppendCc(with WithCc, cc ...*url.URL)

AppendCc appends the given IRIs to the Cc property of 'with'.

func AppendClosed

func AppendClosed(with WithClosed, closed ...time.Time)

AppendClosed appends the given times to the Closed property of 'with'.

func AppendContent added in v0.20.0

func AppendContent(with WithContent, content string)

AppendContent appends the given content string to the `content` property of 'with'.

func AppendContentMap added in v0.20.0

func AppendContentMap(with WithContent, contentMap map[string]string)

AppendContentMap appends the given content language map to the `content` property of 'with'.

func AppendInReplyTo

func AppendInReplyTo(with WithInReplyTo, replyTo ...*url.URL)

AppendInReplyTo appends the given IRIs to the InReplyTo property of 'with'.

func AppendInstrumentIRIs added in v0.20.0

func AppendInstrumentIRIs(with WithInstrument, instrument ...*url.URL)

AppendInstrumentIRIs appends the given IRIs to the Instrument property of 'with'.

func AppendInteractingObject added in v0.20.0

func AppendInteractingObject(with WithInteractingObject, interactingObject ...*url.URL)

AppendInteractingObject appends the given IRIs to the interactingObject property of 'with'.

func AppendInteractionTarget added in v0.20.0

func AppendInteractionTarget(with WithInteractionTarget, interactionTarget ...*url.URL)

AppendInteractionTarget appends the given IRIs to the interactionTarget property of 'with'.

func AppendName added in v0.20.0

func AppendName(with WithName, name ...string)

AppendName appends the given name vals to the Name property of 'with'.

func AppendObjectIRIs

func AppendObjectIRIs(with WithObject, object ...*url.URL)

AppendObjectIRIs appends the given IRIs to the Object property of 'with'.

func AppendResultIRIs added in v0.20.0

func AppendResultIRIs(with WithResult, result ...*url.URL)

AppendResultIRIs appends the given IRIs to the Result property of 'with'.

func AppendSensitive added in v0.20.0

func AppendSensitive(with WithSensitive, sensitive bool)

AppendSensitive appends the given sensitive boolean to the `sensitive` property of 'with'.

func AppendSummary added in v0.20.0

func AppendSummary(with WithSummary, summary ...string)

AppendSummary appends the given summary vals to the Summary property of 'with'.

func AppendTargetIRIs

func AppendTargetIRIs(with WithTarget, target ...*url.URL)

AppendTargetIRIs appends the given IRIs to the Target property of 'with'.

func AppendTo

func AppendTo(with WithTo, to ...*url.URL)

AppendTo appends the given IRIs to the To property of 'with'.

func AppendURL

func AppendURL(with WithURL, url ...*url.URL)

AppendURL appends the given URLs to the URL property of 'with'.

func DecodeType

func DecodeType(
	ctx context.Context,
	body io.ReadCloser,
) (vocab.Type, error)

DecodeType tries to read and parse the data at provided io.ReadCloser as a JSON ActivityPub type, failing if not parseable as JSON or not resolveable as one of our known AS types.

NOTE: this function handles closing given body when it is finished with.

func ExtractAccountables

func ExtractAccountables(arr []TypeOrIRI) ([]Accountable, []TypeOrIRI)

ExtractAccountables extracts Accountable objects from a slice TypeOrIRI, returning extracted and remaining TypeOrIRIs.

func ExtractActorURI

func ExtractActorURI(withActor WithActor) (*url.URL, error)

ExtractActorURI extracts the first Actor URI it can find from a WithActor interface.

func ExtractAttachment

func ExtractAttachment(i Attachmentable) (*gtsmodel.MediaAttachment, error)

ExtractAttachment extracts a minimal gtsmodel.Attachment (just remote URL, description, and blurhash) from the given Attachmentable interface, or an error if no remote URL is set.

func ExtractAttachments

func ExtractAttachments(i WithAttachment) ([]*gtsmodel.MediaAttachment, error)

ExtractAttachments attempts to extract barebones MediaAttachment objects from given AS interface type.

func ExtractAttributedToURI

func ExtractAttributedToURI(i WithAttributedTo) (*url.URL, error)

ExtractAttributedToURI returns the first URI it can find in the given WithAttributedTo, or an error if no URI can be found.

func ExtractBlurhash

func ExtractBlurhash(i WithBlurhash) string

ExtractBlurhash extracts the blurhash string value from the given WithBlurhash interface, or returns an empty string if nothing is found.

func ExtractCcURIs

func ExtractCcURIs(i WithCc) []*url.URL

ExtractCcURIs returns a slice of URIs that the given WithCC addresses as Cc.

func ExtractContent

func ExtractContent(i WithContent) gtsmodel.Content

ExtractContent returns an intermediary representation of the given interface's Content and/or ContentMap property.

func ExtractDescription

func ExtractDescription(i Attachmentable) string

ExtractDescription extracts the image description of an attachmentable, if present. Will try the 'summary' prop first, then fall back to 'name'.

func ExtractEmoji

func ExtractEmoji(
	e Emojiable,
	host string,
) (*gtsmodel.Emoji, error)

ExtractEmoji extracts a minimal gtsmodel.Emoji from the given Emojiable. The host (eg., "example.org") of the emoji should be passed in as well, so that a dummy URI for the emoji can be constructed in case there's no id property or id property is null.

https://codeberg.org/superseriousbusiness/gotosocial/issues/3384)

func ExtractEmojis

func ExtractEmojis(i WithTag, host string) ([]*gtsmodel.Emoji, error)

ExtractEmojis extracts a slice of minimal gtsmodel.Emojis from a WithTag. If an entry in the WithTag is not an emoji, it will be quietly ignored.

func ExtractFields

func ExtractFields(i WithAttachment) []*gtsmodel.Field

ExtractFields extracts property/value fields from the given WithAttachment interface. Will return an empty slice if no property/value fields can be found. Attachments that are not (well-formed) PropertyValues will be ignored.

func ExtractFocus added in v0.20.0

func ExtractFocus(attachmentable Attachmentable) gtsmodel.Focus

ExtractFocus parses a gtsmodel.Focus from the given Attachmentable's `focalPoint` property, if Attachmentable can have `focalPoint`, and `focalPoint` is set to a valid pair of floats. Otherwise, returns a zero gtsmodel.Focus (ie., focus in the centre of the image).

func ExtractHashtags

func ExtractHashtags(i WithTag) ([]*gtsmodel.Tag, error)

ExtractHashtags extracts a slice of minimal gtsmodel.Tags from a WithTag. If an entry in the WithTag is not a hashtag, or has a name that cannot be normalized, it will be ignored.

TODO: find a better heuristic for determining if something is a hashtag or not, since looking for type name "Hashtag" is non-normative. Perhaps look for things that are either type "Hashtag" or have no type name set at all?

func ExtractIconDescription added in v0.20.0

func ExtractIconDescription(i WithIcon) string

ExtractIconDescription extracts the name property from the given WithIcon which links to a supported image file, or returns an empty string. Input will look something like this:

"icon": {
  "mediaType": "image/jpeg",
  "name": "some description",
  "type": "Image",
    "url": "http://example.org/path/to/some/file.jpeg"
  },

func ExtractIconURI

func ExtractIconURI(i WithIcon) (*url.URL, error)

ExtractIconURI extracts the first URI it can find from the given WithIcon which links to a supported image file. Input will look something like this:

"icon": {
  "mediaType": "image/jpeg",
  "type": "Image",
  "url": "http://example.org/path/to/some/file.jpeg"
},

If no valid URI can be found, this will return an error.

func ExtractImageDescription added in v0.20.0

func ExtractImageDescription(i WithImage) string

ExtractImageDescription extracts the name property from the given WithImage which links to a supported image file, or returns an empty string. Input will look something like this:

"image": {
  "mediaType": "image/jpeg",
  "name": "some description",
  "type": "Image",
    "url": "http://example.org/path/to/some/file.jpeg"
  },

func ExtractImageURI

func ExtractImageURI(i WithImage) (*url.URL, error)

ExtractImageURI extracts the first URI it can find from the given WithImage which links to a supported image file. Input will look something like this:

"image": {
  "mediaType": "image/jpeg",
  "type": "Image",
  "url": "http://example.org/path/to/some/file.jpeg"
},

If no valid URI can be found, this will return an error.

func ExtractInReplyToURI

func ExtractInReplyToURI(i WithInReplyTo) *url.URL

ExtractInReplyToURI extracts the first inReplyTo URI property it can find from an interface. Will return nil if no valid URI can be found.

func ExtractInteractionPolicy

func ExtractInteractionPolicy(
	statusable Statusable,
	owner *gtsmodel.Account,
) *gtsmodel.InteractionPolicy

ExtractInteractionPolicy extracts a *gtsmodel.InteractionPolicy from the given Statusable created by by the given *gtsmodel.Account.

Will be nil (default policy) for Statusables that have no policy set on them, or have a null policy. In such a case, the caller should assume the default policy for the status's visibility level.

Sub-policies of the returned policy, eg., CanLike, CanReply, may each be nil if they were not set on the interaction policy.

func ExtractItemsURIs

func ExtractItemsURIs(i WithItems) []*url.URL

ExtractItemsURIs extracts each URI it can find for an item from the provided WithItems.

func ExtractMention

func ExtractMention(i Mentionable) (*gtsmodel.Mention, error)

ExtractMention extracts a minimal gtsmodel.Mention from a Mentionable.

func ExtractMentions

func ExtractMentions(i WithTag) ([]*gtsmodel.Mention, error)

ExtractMentions extracts a slice of minimal gtsmodel.Mentions from a WithTag. If an entry in the WithTag is not a mention, it will be quietly ignored.

func ExtractName

func ExtractName(i WithName) string

ExtractName returns the first string representation it can find of an interface's name property, or an empty string if this is not found.

func ExtractObjectURI

func ExtractObjectURI(withObject WithObject) (*url.URL, error)

ExtractObjectURI extracts the first Object URI it can find from a WithObject interface.

func ExtractObjectURIs

func ExtractObjectURIs(withObject WithObject) ([]*url.URL, error)

ExtractObjectURIs extracts the URLs of each Object it can find from a WithObject interface.

func ExtractPoll

func ExtractPoll(poll Pollable) (*gtsmodel.Poll, error)

ExtractPoll extracts a placeholder Poll from Pollable interface, with available options and flags populated.

func ExtractPollOptionables

func ExtractPollOptionables(arr []TypeOrIRI) ([]PollOptionable, []TypeOrIRI)

ExtractPollOptionables extracts PollOptionable objects from a slice TypeOrIRI, returning extracted and remaining TypeOrIRIs.

func ExtractPreferredUsername

func ExtractPreferredUsername(i WithPreferredUsername) string

ExtractPreferredUsername returns a string representation of an interface's preferredUsername property. Will return an error if preferredUsername is nil, not a string, or empty.

func ExtractPubKeyFromActor

func ExtractPubKeyFromActor(i WithPublicKey) (
	*rsa.PublicKey,
	*url.URL,
	*url.URL,
	error,
)

ExtractPubKeyFromActor extracts the public key, public key ID, and public key owner ID from an interface, or an error if something goes wrong.

func ExtractPubKeyFromKey

func ExtractPubKeyFromKey(pkey vocab.W3IDSecurityV1PublicKey) (
	*rsa.PublicKey,
	*url.URL,
	*url.URL,
	error,
)

ExtractPubKeyFromActor extracts the public key, public key ID, and public key owner ID from an interface, or an error if something goes wrong.

func ExtractSensitive

func ExtractSensitive(withSensitive WithSensitive) bool

ExtractSensitive extracts whether or not an item should be marked as sensitive according to its ActivityStreams sensitive property.

If no sensitive property is set on the item at all, or if this property isn't a boolean, then false will be returned by default.

func ExtractSharedInbox

func ExtractSharedInbox(withEndpoints WithEndpoints) *url.URL

ExtractSharedInbox extracts the sharedInbox URI property from an Actor. Returns nil if this property is not set.

func ExtractStatusables

func ExtractStatusables(arr []TypeOrIRI) ([]Statusable, []TypeOrIRI)

ExtractStatusables extracts Statusable objects from a slice TypeOrIRI, returning extracted and remaining TypeOrIRIs.

func ExtractSummary

func ExtractSummary(i WithSummary) string

ExtractSummary extracts the summary/content warning of the given WithSummary interface. Will return an empty string if no summary/content warning was present.

func ExtractToURIs

func ExtractToURIs(i WithTo) []*url.URL

ExtractToURIs returns a slice of URIs that the given WithTo addresses as To.

func ExtractVisibility

func ExtractVisibility(addressable Addressable, actorFollowersURI string) (gtsmodel.Visibility, error)

ExtractVisibility extracts the gtsmodel.Visibility of a given addressable with a To and CC property.

ActorFollowersURI is needed to check whether the visibility is FollowersOnly or not. The passed-in value should just be the string value representation of the followers URI of the actor who created the activity, eg., `https://example.org/users/whoever/followers`.

func GetActorIRIs

func GetActorIRIs(with WithActor) []*url.URL

GetActorIRIs returns the IRIs contained in the Actor property of 'with'.

func GetAlsoKnownAs

func GetAlsoKnownAs(with WithAlsoKnownAs) []*url.URL

GetAlsoKnownAs returns the IRI contained in the alsoKnownAs property of 'with'.

func GetAnnounceAuthorization added in v0.20.0

func GetAnnounceAuthorization(with WithAnnounceAuthorization) *url.URL

GetAnnounceAuthorization returns the URL contained in the announceAuthorization property of 'with', if set.

func GetApprovedBy

func GetApprovedBy(with WithApprovedBy) *url.URL

GetApprovedBy returns the URL contained in the ApprovedBy property of 'with', if set.

func GetAttributedTo

func GetAttributedTo(with WithAttributedTo) []*url.URL

GetAttributedTo returns the IRIs contained in the AttributedTo property of 'with'.

func GetBcc

func GetBcc(with WithBcc) []*url.URL

GetBcc returns the IRIs contained in the Bcc property of 'with'. Panics on entries with missing ID.

func GetCc

func GetCc(with WithCc) []*url.URL

GetCc returns the IRIs contained in the Cc property of 'with'. Panics on entries with missing ID.

func GetClosed

func GetClosed(with WithClosed) []time.Time

GetEndTime returns the times contained in the Closed property of 'with'.

func GetDiscoverable

func GetDiscoverable(with WithDiscoverable) bool

GetDiscoverable returns the boolean contained in the Discoverable property of 'with'.

Returns default 'false' if property unusable or not set.

func GetEndTime

func GetEndTime(with WithEndTime) time.Time

GetEndTime returns the time contained in the EndTime property of 'with'.

func GetFeatured

func GetFeatured(with WithFeatured) *url.URL

GetFeatured returns the IRI contained in the Featured property of 'with'.

func GetFollowers

func GetFollowers(with WithFollowers) *url.URL

GetFollowers returns the IRI contained in the Followers property of 'with'.

func GetFollowing

func GetFollowing(with WithFollowing) *url.URL

GetFollowers returns the IRI contained in the Following property of 'with'.

func GetHidesCcPublicFromUnauthedWeb added in v0.20.0

func GetHidesCcPublicFromUnauthedWeb(with WithHidesCcPublicFromUnauthedWeb) bool

GetHidesCcPublicFromUnauthedWeb returns the boolean contained in the hidesCcPublicFromUnauthedWeb property of 'with'.

Returns default 'true' if property unusable or not set.

func GetHidesToPublicFromUnauthedWeb added in v0.20.0

func GetHidesToPublicFromUnauthedWeb(with WithHidesToPublicFromUnauthedWeb) bool

GetHidesToPublicFromUnauthedWeb returns the boolean contained in the hidesToPublicFromUnauthedWeb property of 'with'.

Returns default 'false' if property unusable or not set.

func GetInReplyTo

func GetInReplyTo(with WithInReplyTo) []*url.URL

GetInReplyTo returns the IRIs contained in the InReplyTo property of 'with'.

func GetInbox

func GetInbox(with WithInbox) *url.URL

GetInbox returns the IRI contained in the Inbox property of 'with'.

func GetInteractingObject added in v0.20.0

func GetInteractingObject(with WithInteractingObject) []*url.URL

GetInteractingObject returns IRIs contained in the interactingObject property of 'with'.

func GetInteractionTarget added in v0.20.0

func GetInteractionTarget(with WithInteractionTarget) []*url.URL

GetInteractionTarget returns IRIs contained in the interactionTarget property of 'with'.

func GetJSONLDId

func GetJSONLDId(with WithJSONLDId) *url.URL

GetJSONLDId returns the ID of 'with', or nil.

func GetLikeAuthorization added in v0.20.0

func GetLikeAuthorization(with WithLikeAuthorization) *url.URL

GetLikeAuthorization returns the URL contained in the likeAuthorization property of 'with', if set.

func GetManuallyApprovesFollowers

func GetManuallyApprovesFollowers(with WithManuallyApprovesFollowers) bool

GetManuallyApprovesFollowers returns the boolean contained in the ManuallyApprovesFollowers property of 'with'.

Returns default 'false' if property unusable or not set.

func GetMediaType added in v0.20.0

func GetMediaType(with WithMediaType) string

GetMediaType returns the string contained in the MediaType property of 'with', if set.

func GetMovedTo

func GetMovedTo(with WithMovedTo) *url.URL

GetMovedTo returns the IRI contained in the movedTo property of 'with'.

func GetObjectIRIs

func GetObjectIRIs(with WithObject) []*url.URL

GetObjectIRIs returns the IRIs contained in the Object property of 'with'.

func GetOutbox

func GetOutbox(with WithOutbox) *url.URL

GetOutbox returns the IRI contained in the Outbox property of 'with'.

func GetPublished

func GetPublished(with WithPublished) time.Time

GetPublished returns the time contained in the Published property of 'with'.

func GetReplyAuthorization added in v0.20.0

func GetReplyAuthorization(with WithReplyAuthorization) *url.URL

GetReplyAuthorization returns the URL contained in the replyAuthorization property of 'with', if set.

func GetResultIRIs added in v0.20.0

func GetResultIRIs(with WithResult) []*url.URL

GetResultIRIs returns the IRIs contained in the `result` property of 'with'.

func GetTargetIRIs

func GetTargetIRIs(with WithTarget) []*url.URL

GetTargetIRIs returns the IRIs contained in the Target property of 'with'.

func GetTo

func GetTo(with WithTo) []*url.URL

GetTo returns the IRIs contained in the To property of 'with'. Panics on entries with missing ID.

func GetURL

func GetURL(with WithURL) []*url.URL

GetURL returns IRIs contained in the URL property of 'with'.

func GetUpdated

func GetUpdated(with WithUpdated) time.Time

GetUpdated returns the time contained in the Updated property of 'with'.

func GetVotersCount

func GetVotersCount(with WithVotersCount) int

GetVotersCount returns the integer contained in the VotersCount property of 'with', if found.

func IsAcceptable

func IsAcceptable(typeName string) bool

IsAccept returns whether AS vocab type name is something that can be cast to Acceptable.

func IsAccountable

func IsAccountable(typeName string) bool

IsAccountable returns whether AS vocab type name is acceptable as Accountable.

func IsActivityable

func IsActivityable(typeName string) bool

IsActivityable returns whether AS vocab type name is acceptable as Activityable.

func IsAnnounceable added in v0.20.0

func IsAnnounceable(typeName string) bool

IsAnnounceable returns whether AS vocab type name is something that can be cast to vocab.ActivityStreamsAnnounce.

func IsAttachmentable added in v0.20.0

func IsAttachmentable(typeName string) bool

IsAttachmentable returns whether AS vocab type name is something that can be cast to Attachmentable.

func IsAuthorizationable added in v0.20.0

func IsAuthorizationable(typeName string) bool

IsAuthorizationable returns whether AS vocab type name is something that can be cast to Authorizationable.

func IsLikeable added in v0.20.0

func IsLikeable(typeName string) bool

IsLikeable returns whether AS vocab type name is something that can be cast to vocab.ActivityStreamsLike.

func IsPollOptionable

func IsPollOptionable(typeName string) bool

IsPollOptionable returns whether AS vocab type name is acceptable as PollOptionable.

func IsPollable

func IsPollable(typeName string) bool

IsPollable returns whether AS vocab type name is acceptable as Pollable.

func IsStatusable

func IsStatusable(typeName string) bool

IsStatusable returns whether AS vocab type name is acceptable as Statusable.

func IterateAnyOf

func IterateAnyOf(withAnyOf WithAnyOf, foreach func(vocab.ActivityStreamsAnyOfPropertyIterator))

IterateAnyOf will attempt to extract anyOf property from given interface, and passes each iterated item to function.

func IterateOneOf

func IterateOneOf(withOneOf WithOneOf, foreach func(vocab.ActivityStreamsOneOfPropertyIterator))

IterateOneOf will attempt to extract oneOf property from given interface, and passes each iterated item to function.

func MustSet

func MustSet[W, T any](fn func(W, T) error, with W, value T)

MustSet performs the given 'Set$Property(with, T) error' signature function, panicking on error.

func NewASCollection

func NewASCollection(params CollectionParams) vocab.ActivityStreamsCollection

NewASCollection builds and returns a new ActivityStreams Collection from given parameters.

func NewASCollectionPage

func NewASCollectionPage(params CollectionPageParams) vocab.ActivityStreamsCollectionPage

NewASCollectionPage builds and returns a new ActivityStreams CollectionPage from given parameters (including item property appending function).

func NewASOrderedCollection

func NewASOrderedCollection(params CollectionParams) vocab.ActivityStreamsOrderedCollection

NewASOrderedCollection builds and returns a new ActivityStreams OrderedCollection from given parameters.

func NewASOrderedCollectionPage

func NewASOrderedCollectionPage(params CollectionPageParams) vocab.ActivityStreamsOrderedCollectionPage

NewASOrderedCollectionPage builds and returns a new ActivityStreams OrderedCollectionPage from given parameters (including item property appending function).

func NormalizeIncomingActivity

func NormalizeIncomingActivity(activity pub.Activity, rawJSON map[string]interface{})

NormalizeIncomingActivityObject normalizes the 'object'.'content' field of the given Activity.

The rawActivity map should the freshly deserialized json representation of the Activity.

This function is a noop if the type passed in is anything except a Create or Update with a Statusable or Accountable as its Object.

func NormalizeIncomingAttachments

func NormalizeIncomingAttachments(item WithAttachment, rawJSON map[string]interface{})

NormalizeIncomingAttachments normalizes all attachments (if any) of the given item, replacing the 'name' (aka content warning) field of each attachment with the raw 'name' value from the raw json object map, and doing sanitization on the result.

noop if there are no attachments; noop if attachment is not a format we can understand.

func NormalizeIncomingContent

func NormalizeIncomingContent(item WithContent, rawJSON map[string]interface{})

NormalizeIncomingContent replaces the Content property of the given item with the normalized versions of the raw 'content' and 'contentMap' values from the raw json object map.

noop if there was no 'content' or 'contentMap' in the json object map.

func NormalizeIncomingFields

func NormalizeIncomingFields(item WithAttachment, rawJSON map[string]interface{})

NormalizeIncomingFields sanitizes any PropertyValue fields on the given WithAttachment interface, by removing html completely from the "name" field, and sanitizing dodgy HTML out of the "value" field.

func NormalizeIncomingName

func NormalizeIncomingName(item WithName, rawJSON map[string]interface{})

NormalizeIncomingName replaces the Name of the given item with the raw 'name' value from the raw json object map.

noop if there was no name in the json object map or the name was not a plain string.

func NormalizeIncomingPollOptions

func NormalizeIncomingPollOptions(item WithOneOf, rawJSON map[string]interface{})

NormalizeIncomingOneOf normalizes all oneOf (if any) of the given item, replacing the 'name' field of each oneOf with the raw 'name' value from the raw json object map, and doing sanitization on the result.

noop if there are no oneOf; noop if oneOf is not expected format.

func NormalizeIncomingSummary

func NormalizeIncomingSummary(item WithSummary, rawJSON map[string]interface{})

NormalizeIncomingSummary replaces the Summary of the given item with the sanitized version of the raw 'summary' value from the raw json object map.

noop if there was no summary in the json object map or the summary was not a plain string.

func NormalizeIncomingValue

func NormalizeIncomingValue(item WithValue, rawJSON map[string]interface{})

NormalizeIncomingValue replaces the Value of the given tem with the raw 'value' from the raw json object map.

noop if there was no name in the json object map or the value was not a plain string.

func NormalizeOutgoingAlsoKnownAsProp

func NormalizeOutgoingAlsoKnownAsProp(item WithAlsoKnownAs, rawJSON map[string]interface{})

NormalizeOutgoingAlsoKnownAsProp replaces single-entry alsoKnownAs values with single-entry arrays, for better compatibility with other AP implementations.

Ie:

"alsoKnownAs": "https://example.org/users/some_user"

becomes:

"alsoKnownAs": ["https://example.org/users/some_user"]

Noop for items with no attachments, or with attachments that are already a slice.

func NormalizeOutgoingAttachmentProp

func NormalizeOutgoingAttachmentProp(item WithAttachment, rawJSON map[string]interface{})

NormalizeOutgoingAttachmentProp replaces single-entry Attachment objects with single-entry arrays, for better compatibility with other AP implementations.

Ie:

"attachment": {
  ...
}

becomes:

"attachment": [
  {
    ...
  }
]

Noop for items with no attachments, or with attachments that are already a slice.

func NormalizeOutgoingContentProp

func NormalizeOutgoingContentProp(item WithContent, rawJSON map[string]interface{})

NormalizeOutgoingContentProp normalizes go-fed's funky formatting of content and contentMap properties to a format better understood by other AP implementations.

Ie., incoming "content" property like this:

"content": [
  "hello world!",
  {
    "en": "hello world!"
  }
]

Is unpacked to:

"content": "hello world!",
"contentMap": {
  "en": "hello world!"
}

Noop if neither content nor contentMap are set.

func NormalizeOutgoingInteractionPolicyProp

func NormalizeOutgoingInteractionPolicyProp(item WithInteractionPolicy, rawJSON map[string]interface{})

NormalizeOutgoingInteractionPolicyProp replaces single-entry interactionPolicy values with single-entry arrays, for better compatibility with other AP implementations.

Ie:

"interactionPolicy": {
	"canAnnounce": {
		"automaticApproval": "https://www.w3.org/ns/activitystreams#Public",
		"manualApproval": []
	},
	"canLike": {
		"automaticApproval": "https://www.w3.org/ns/activitystreams#Public",
		"manualApproval": []
	},
	"canReply": {
		"automaticApproval": "https://www.w3.org/ns/activitystreams#Public",
		"manualApproval": []
	}
}

becomes:

"interactionPolicy": {
	"canAnnounce": {
		"automaticApproval": [
			"https://www.w3.org/ns/activitystreams#Public"
		],
		"manualApproval": []
	},
	"canLike": {
		"automaticApproval": [
			"https://www.w3.org/ns/activitystreams#Public"
		],
		"manualApproval": []
	},
	"canReply": {
		"automaticApproval": [
			"https://www.w3.org/ns/activitystreams#Public"
		],
		"manualApproval": []
	}
}

Noop for items with no attachments, or with attachments that are already a slice.

func NormalizeOutgoingObjectProp

func NormalizeOutgoingObjectProp(item WithObject, rawJSON map[string]interface{}) error

NormalizeOutgoingObjectProp normalizes each Object entry in the rawJSON of the given item by calling custom serialization / normalization functions on them in turn.

This function also unnests single-entry arrays, so that:

"object": [
  {
    ...
  }
]

Becomes:

"object": {
  ...
}

Noop for each Object entry that isn't an Accountable or Statusable.

func PublicIRI added in v0.20.0

func PublicIRI() *url.URL

PublicIRI returns a fresh copy of the *url.URL version of the magic ActivityPub URI https://www.w3.org/ns/activitystreams#Public

func ResolveIncomingActivity

func ResolveIncomingActivity(r *http.Request) (pub.Activity, bool, gtserror.WithCode)

ResolveActivity is a util function for pulling a pub.Activity type out of an incoming request body, returning the resolved activity type, error and whether to accept activity (false = transient i.e. ignore).

func Serialize

func Serialize(t vocab.Type) (m map[string]interface{}, e error)

Serialize is a custom serializer for ActivityStreams types.

In most cases, it will simply call the go-fed streams.Serialize function under the hood. However, if custom serialization is required on a specific type (eg for inter-implementation compatibility), it can be inserted into the switch as necessary.

Callers should always call this function instead of streams.Serialize, unless there's a very good reason to do otherwise.

Currently, the following things will be custom serialized:

  • OrderedCollection: 'orderedItems' property will always be made into an array.
  • OrderedCollectionPage: 'orderedItems' property will always be made into an array.
  • Any Accountable type: 'attachment' property will always be made into an array.
  • Any Statusable type: 'attachment' property will always be made into an array; 'content', 'contentMap', and 'interactionPolicy' will be normalized.
  • Any Activityable type: any 'object's set on an activity will be custom serialized as above.

func SetAlsoKnownAs

func SetAlsoKnownAs(with WithAlsoKnownAs, alsoKnownAs []*url.URL)

SetAlsoKnownAs sets the given IRIs on the alsoKnownAs property of 'with'.

func SetAnnounceAuthorization added in v0.20.0

func SetAnnounceAuthorization(with WithAnnounceAuthorization, announceAuthorization *url.URL)

SetAnnounceAuthorization sets the given url on the 'announceAuthorization' property of 'with'.

func SetApprovedBy

func SetApprovedBy(with WithApprovedBy, approvedBy *url.URL)

SetApprovedBy sets the given url on the ApprovedBy property of 'with'.

func SetBlurhash added in v0.20.0

func SetBlurhash(with WithBlurhash, mediaType string)

SetBlurhash sets the given string on the Blurhash property of 'with'.

func SetDiscoverable

func SetDiscoverable(with WithDiscoverable, discoverable bool)

SetDiscoverable sets the given boolean on the Discoverable property of 'with'.

func SetEndTime

func SetEndTime(with WithEndTime, end time.Time)

SetEndTime sets the given time on the EndTime property of 'with'.

func SetFeatured

func SetFeatured(with WithFeatured, featured *url.URL)

SetFeatured sets the given IRI on the Featured property of 'with'.

func SetFollowers

func SetFollowers(with WithFollowers, followers *url.URL)

SetFollowers sets the given IRI on the Followers property of 'with'.

func SetFollowing

func SetFollowing(with WithFollowing, following *url.URL)

SetFollowers sets the given IRI on the Following property of 'with'.

func SetHidesCcPublicFromUnauthedWeb added in v0.20.0

func SetHidesCcPublicFromUnauthedWeb(with WithHidesCcPublicFromUnauthedWeb, hidesCcPublicFromUnauthedWeb bool)

SetHidesCcPublicFromUnauthedWeb sets the given boolean on the hidesCcPublicFromUnauthedWeb property of 'with'.

func SetHidesToPublicFromUnauthedWeb added in v0.20.0

func SetHidesToPublicFromUnauthedWeb(with WithHidesToPublicFromUnauthedWeb, hidesToPublicFromUnauthedWeb bool)

SetHidesToPublicFromUnauthedWeb sets the given boolean on the hidesToPublicFromUnauthedWeb property of 'with'.

func SetInbox

func SetInbox(with WithInbox, inbox *url.URL)

SetInbox sets the given IRI on the Inbox property of 'with'.

func SetJSONLDId

func SetJSONLDId(with WithJSONLDId, id *url.URL)

SetJSONLDId sets the given URL to the JSONLD ID of 'with'.

func SetJSONLDIdStr

func SetJSONLDIdStr(with WithJSONLDId, id string) error

SetJSONLDIdStr sets the given string to the JSONLDID of 'with'. Returns error

func SetLikeAuthorization added in v0.20.0

func SetLikeAuthorization(with WithLikeAuthorization, likeAuthorization *url.URL)

SetLikeAuthorization sets the given url on the 'likeAuthorization' property of 'with'.

func SetManuallyApprovesFollowers

func SetManuallyApprovesFollowers(with WithManuallyApprovesFollowers, manuallyApprovesFollowers bool)

SetManuallyApprovesFollowers sets the given boolean on the ManuallyApprovesFollowers property of 'with'.

func SetMediaType added in v0.20.0

func SetMediaType(with WithMediaType, mediaType string)

SetMediaType sets the given string on the MediaType property of 'with'.

func SetMovedTo

func SetMovedTo(with WithMovedTo, movedTo *url.URL)

SetMovedTo sets the given IRI on the movedTo property of 'with'.

func SetOutbox

func SetOutbox(with WithOutbox, outbox *url.URL)

SetOutbox sets the given IRI on the Outbox property of 'with'.

func SetPublished

func SetPublished(with WithPublished, published time.Time)

SetPublished sets the given time on the Published property of 'with'.

func SetReplies added in v0.20.0

func SetReplies(with WithReplies, replies vocab.ActivityStreamsCollection)

SetReplies sets the given replies collection to the `replies` property of 'with'.

func SetReplyAuthorization added in v0.20.0

func SetReplyAuthorization(with WithReplyAuthorization, replyAuthorization *url.URL)

SetReplyAuthorization sets the given url on the 'replyAuthorization' property of 'with'.

func SetUpdated

func SetUpdated(with WithUpdated, updated time.Time)

SetUpdated sets the given time on the Updated property of 'with'.

func SetVotersCount

func SetVotersCount(with WithVotersCount, count int)

SetVotersCount sets the given count on the VotersCount property of 'with'.

func ToAnnounceable added in v0.20.0

func ToAnnounceable(t vocab.Type) (vocab.ActivityStreamsAnnounce, bool)

ToAnnounceable safely tries to cast vocab.Type as vocab.ActivityStreamsAnnounce.

func ToLikeable added in v0.20.0

func ToLikeable(t vocab.Type) (vocab.ActivityStreamsLike, bool)

ToAnnouncToLikeableeable safely tries to cast vocab.Type as vocab.ActivityStreamsLike.

Types

type Acceptable

type Acceptable interface {
	Activityable

	WithTarget
	WithResult
}

Acceptable represents the minimum activitypub interface for representing an Accept.

func ToAcceptable

func ToAcceptable(t vocab.Type) (Acceptable, bool)

ToAcceptable safely tries to cast vocab.Type as Acceptable.

type Accountable

Accountable represents the minimum activitypub interface for representing an 'account'. (see: IsAccountable() for types implementing this, though you MUST make sure to check the typeName as this bare interface may be implementable by non-Accountable types).

func ResolveAccountable

func ResolveAccountable(ctx context.Context, body io.ReadCloser) (Accountable, error)

ResolveAccountable tries to resolve the given reader into an ActivityPub Accountable representation. It will then perform normalization on the Accountable.

Works for: Application, Group, Organization, Person, Service

func ToAccountable

func ToAccountable(t vocab.Type) (Accountable, bool)

ToAccountable safely tries to cast vocab.Type as Accountable, also checking for expected AS type names.

type Activityable

type Activityable interface {
	// Activity is also a vocab.Type
	vocab.Type

	WithTo
	WithCc
	WithBcc
	WithAttributedTo
	WithActor
	WithObject
	WithPublished
}

Activityable represents the minimum activitypub interface for representing an 'activity'. (see: IsActivityable() for types implementing this, though you MUST make sure to check the typeName as this bare interface may be implementable by non-Activityable types).

func ToActivityable

func ToActivityable(t vocab.Type) (Activityable, bool)

ToActivityable safely tries to cast vocab.Type as Activityable, also checking for expected AS type names.

type Addressable

type Addressable interface {
	WithTo
	WithCc
}

Addressable represents the minimum interface for an addressed activity.

type Announceable

Announceable represents the minimum interface for an activitystreams 'announce' activity.

type Attachmentable

Attachmentable represents the minimum activitypub interface for representing a 'mediaAttachment'. (see: IsAttachmentable). This interface is fulfilled by: Audio, Document, Image, Video

func ToAttachmentable added in v0.20.0

func ToAttachmentable(t vocab.Type) (Attachmentable, bool)

ToAttachmentable safely tries to cast vocab.Type as Attachmentable.

type Authorizationable added in v0.20.0

Authorizationable represents the minimum interface for a LikeAuthorization, ReplyAuthorization, AnnounceAuthorization.

func ToAuthorizationable added in v0.20.0

func ToAuthorizationable(t vocab.Type) (Authorizationable, bool)

ToAcceptable safely tries to cast vocab.Type as Approvable.

type Blockable

type Blockable interface {
	WithJSONLDId
	WithTypeName

	WithActor
	WithObject
}

Blockable represents the minimum interface for an activitystreams 'block' activity.

type CollectionBuilder

type CollectionBuilder interface {
	SetJSONLDId(vocab.JSONLDIdProperty)
	SetActivityStreamsFirst(vocab.ActivityStreamsFirstProperty)
	SetActivityStreamsTotalItems(i vocab.ActivityStreamsTotalItemsProperty)
}

CollectionPage is a simplified interface type that can be fulfilled by either of (where required): vocab.ActivityStreamsCollection vocab.ActivityStreamsOrderedCollection

type CollectionIterator

type CollectionIterator interface {
	vocab.Type

	NextItem() TypeOrIRI
	PrevItem() TypeOrIRI

	// TotalItems returns the total items
	// present in the collection, derived
	// from the totalItems property, or -1
	// if totalItems not present / readable.
	TotalItems() int
}

CollectionIterator represents the minimum interface for interacting with a wrapped Collection or OrderedCollection in order to access next / prev items.

func ResolveCollection

func ResolveCollection(ctx context.Context, body io.ReadCloser) (CollectionIterator, error)

ResolveCollection tries to resolve the given reader into an ActivityPub Collection-like representation, then wrapping as abstracted iterator. Works for: Collection, OrderedCollection.

func ToCollectionIterator

func ToCollectionIterator(t vocab.Type) (CollectionIterator, error)

ToCollectionIterator attempts to resolve the given vocab type as a Collection like object and wrap in a standardised interface in order to iterate its contents.

func WrapCollection

func WrapCollection(collection vocab.ActivityStreamsCollection) CollectionIterator

WrapCollection wraps an ActivityStreamsCollection in a standardised collection interface.

func WrapOrderedCollection

func WrapOrderedCollection(collection vocab.ActivityStreamsOrderedCollection) CollectionIterator

WrapOrderedCollection wraps an ActivityStreamsOrderedCollection in a standardised collection interface.

type CollectionPageBuilder

type CollectionPageBuilder interface {
	SetJSONLDId(vocab.JSONLDIdProperty)
	SetActivityStreamsPartOf(vocab.ActivityStreamsPartOfProperty)
	SetActivityStreamsNext(vocab.ActivityStreamsNextProperty)
	SetActivityStreamsPrev(vocab.ActivityStreamsPrevProperty)
	SetActivityStreamsTotalItems(i vocab.ActivityStreamsTotalItemsProperty)
}

CollectionPageBuilder is a simplified interface type that can be fulfilled by either of (where required): vocab.ActivityStreamsCollectionPage vocab.ActivityStreamsOrderedCollectionPage

type CollectionPageIterator

type CollectionPageIterator interface {
	vocab.Type

	NextPage() WithIRI
	PrevPage() WithIRI

	NextItem() TypeOrIRI
	PrevItem() TypeOrIRI

	// TotalItems returns the total items
	// present in the collection, derived
	// from the totalItems property, or -1
	// if totalItems not present / readable.
	TotalItems() int
}

CollectionPageIterator represents the minimum interface for interacting with a wrapped CollectionPage or OrderedCollectionPage in order to access both next / prev pages and items.

func ResolveCollectionPage

func ResolveCollectionPage(ctx context.Context, body io.ReadCloser) (CollectionPageIterator, error)

ResolveCollectionPage tries to resolve the given reader into an ActivityPub CollectionPage-like representation, then wrapping as abstracted iterator. Works for: CollectionPage, OrderedCollectionPage.

func ToCollectionPageIterator

func ToCollectionPageIterator(t vocab.Type) (CollectionPageIterator, error)

ToCollectionPageIterator attempts to resolve the given vocab type as a CollectionPage like object and wrap in a standardised interface in order to iterate its contents.

func WrapCollectionPage

WrapCollectionPage wraps an ActivityStreamsCollectionPage in a standardised collection page interface.

func WrapOrderedCollectionPage

WrapOrderedCollectionPage wraps an ActivityStreamsOrderedCollectionPage in a standardised collection page interface.

type CollectionPageParams

type CollectionPageParams struct {
	// containing collection.
	CollectionParams

	// Paging details.
	Current *paging.Page
	Next    *paging.Page
	Prev    *paging.Page
	Query   url.Values

	// Item appender for each item at index.
	Append func(int, ItemsPropertyBuilder)
	Count  int
}

type CollectionParams

type CollectionParams struct {
	// Containing collection
	// ID (i.e. NOT the page).
	ID *url.URL

	// First page details.
	First *paging.Page
	Query url.Values

	// Total no. items.
	// Omitted if nil.
	Total *int
}

type Emojiable

type Emojiable interface {
	WithJSONLDId
	WithTypeName
	WithName
	WithUpdated
	WithIcon
}

Emojiable represents the minimum interface for an 'emoji' tag.

type Flaggable

Flaggable represents the minimum interface for an activitystreams 'Flag' activity.

type Followable

type Followable interface {
	WithJSONLDId
	WithTypeName

	WithActor
	WithObject
}

Followable represents the minimum interface for an activitystreams 'follow' activity.

type Hashtaggable

type Hashtaggable interface {
	WithTypeName
	WithHref
	WithName
}

Hashtaggable represents the minimum activitypub interface for representing a 'hashtag' tag.

type InteractionRequestable added in v0.20.0

type InteractionRequestable interface {
	vocab.Type

	WithActor
	WithObject
	WithInstrument
}

InteractionRequestable represents the minimum interface for an interaction request activity, eg., LikeRequest, ReplyRequest, AnnounceRequest, QuoteRequest, etc..

type ItemsPropertyBuilder

type ItemsPropertyBuilder interface {
	AppendIRI(*url.URL)
	AppendActivityStreamsCreate(vocab.ActivityStreamsCreate)
}

ItemsPropertyBuilder is a simplified interface type that can be fulfilled by either of (where required): vocab.ActivityStreamsItemsProperty vocab.ActivityStreamsOrderedItemsProperty

type Likeable

type Likeable interface {
	WithJSONLDId
	WithTypeName

	WithActor
	WithObject
}

Likeable represents the minimum interface for an activitystreams 'like' activity.

type Mentionable

type Mentionable interface {
	WithName
	WithHref
}

Mentionable represents the minimum interface for a 'mention' tag.

type PollOptionable

type PollOptionable interface {
	vocab.Type

	WithName
	WithTo
	WithInReplyTo
	WithReplies
	WithAttributedTo
}

PollOptionable represents the minimum activitypub interface for representing a poll 'vote'. (see: IsPollOptionable() for types implementing this, though you MUST make sure to check the typeName as this bare interface may be implementable by non-Pollable types).

func ToPollOptionable

func ToPollOptionable(t vocab.Type) (PollOptionable, bool)

ToPollOptionable safely tries to cast vocab.Type as PollOptionable, also checking for expected AS type names.

type Pollable

type Pollable interface {
	WithOneOf
	WithAnyOf
	WithEndTime
	WithClosed
	WithVotersCount

	// base-interfaces
	Statusable
}

Pollable represents the minimum activitypub interface for representing a 'poll' (it's a subset of a status). (see: IsPollable() for types implementing this, though you MUST make sure to check the typeName as this bare interface may be implementable by non-Pollable types).

func ToPollable

func ToPollable(t vocab.Type) (Pollable, bool)

ToPollable safely tries to cast vocab.Type as Pollable, also checking for expected AS type names.

type Property

type Property[T WithIRI] interface {
	Len() int
	At(int) T

	AppendIRI(*url.URL)
	SetIRI(int, *url.URL)
}

Property represents the minimum interface for an ActivityStreams property with IRIs.

type ReplyToable

type ReplyToable interface {
	WithInReplyTo
}

ReplyToable represents the minimum interface for an Activity that can be InReplyTo another activity.

type Statusable

Statusable represents the minimum activitypub interface for representing a 'status'. (see: IsStatusable() for types implementing this, though you MUST make sure to check the typeName as this bare interface may be implementable by non-Statusable types).

func ResolveStatusable

func ResolveStatusable(ctx context.Context, body io.ReadCloser) (Statusable, error)

ResolveStatusable tries to resolve the response data as an ActivityPub Statusable representation. It will then perform normalization on the Statusable.

Works for: Article, Document, Image, Video, Note, Page, Event, Place, Profile, Question.

func ToStatusable

func ToStatusable(t vocab.Type) (Statusable, bool)

ToStatusable safely tries to cast vocab.Type as Statusable, also checking for expected AS type names.

type TypeOrIRI

type TypeOrIRI interface {
	WithIRI
	WithType
}

TypeOrIRI represents the minimum interface for something that may be a vocab.Type OR IRI.

func ExtractActivityData

func ExtractActivityData(activity pub.Activity, rawJSON map[string]any) ([]TypeOrIRI, []any, bool)

ExtractActivityData will extract the usable data type (e.g. Note, Question, etc) and corresponding JSON, from activity.

func ExtractInstruments added in v0.20.0

func ExtractInstruments(with WithInstrument) []TypeOrIRI

ExtractInstrument will extract instrument TypeOrIRIs from given implementing interface.

func ExtractObjects

func ExtractObjects(with WithObject) []TypeOrIRI

ExtractObjects will extract object TypeOrIRIs from given implementing interface.

type WithActor

type WithActor interface {
	GetActivityStreamsActor() vocab.ActivityStreamsActorProperty
	SetActivityStreamsActor(vocab.ActivityStreamsActorProperty)
}

WithActor represents an activity with ActivityStreamsActorProperty

type WithAlsoKnownAs

type WithAlsoKnownAs interface {
	GetActivityStreamsAlsoKnownAs() vocab.ActivityStreamsAlsoKnownAsProperty
	SetActivityStreamsAlsoKnownAs(vocab.ActivityStreamsAlsoKnownAsProperty)
}

WithAlsoKnownAs represents an Object with ActivityStreamsAlsoKnownAsProperty.

type WithAnnounceAuthorization added in v0.20.0

type WithAnnounceAuthorization interface {
	GetGoToSocialAnnounceAuthorization() vocab.GoToSocialAnnounceAuthorizationProperty
	SetGoToSocialAnnounceAuthorization(vocab.GoToSocialAnnounceAuthorizationProperty)
}

WithAnnounceAuthorization represents an Announceable with the announceAuthorization property.

type WithAnyOf

type WithAnyOf interface {
	GetActivityStreamsAnyOf() vocab.ActivityStreamsAnyOfProperty
	SetActivityStreamsAnyOf(vocab.ActivityStreamsAnyOfProperty)
}

WithOneOf represents an activity with the oneOf property.

type WithApprovedBy

type WithApprovedBy interface {
	GetGoToSocialApprovedBy() vocab.GoToSocialApprovedByProperty
	SetGoToSocialApprovedBy(vocab.GoToSocialApprovedByProperty)
}

WithApprovedBy represents an object with the approvedBy property.

type WithAttachment

type WithAttachment interface {
	GetActivityStreamsAttachment() vocab.ActivityStreamsAttachmentProperty
	SetActivityStreamsAttachment(vocab.ActivityStreamsAttachmentProperty)
}

WithAttachment represents an activity with ActivityStreamsAttachmentProperty

type WithAttributedTo

type WithAttributedTo interface {
	GetActivityStreamsAttributedTo() vocab.ActivityStreamsAttributedToProperty
	SetActivityStreamsAttributedTo(vocab.ActivityStreamsAttributedToProperty)
}

WithAttributedTo represents an activity with ActivityStreamsAttributedToProperty

type WithBcc

type WithBcc interface {
	GetActivityStreamsBcc() vocab.ActivityStreamsBccProperty
	SetActivityStreamsBcc(vocab.ActivityStreamsBccProperty)
}

WithCC represents an activity with ActivityStreamsBccProperty

type WithBlurhash

type WithBlurhash interface {
	GetTootBlurhash() vocab.TootBlurhashProperty
	SetTootBlurhash(vocab.TootBlurhashProperty)
}

WithBlurhash represents an activity with TootBlurhashProperty

type WithCc

type WithCc interface {
	GetActivityStreamsCc() vocab.ActivityStreamsCcProperty
	SetActivityStreamsCc(vocab.ActivityStreamsCcProperty)
}

WithCC represents an activity with ActivityStreamsCcProperty

type WithClosed

type WithClosed interface {
	GetActivityStreamsClosed() vocab.ActivityStreamsClosedProperty
	SetActivityStreamsClosed(vocab.ActivityStreamsClosedProperty)
}

WithClosed represents an activity with the closed property.

type WithContent

type WithContent interface {
	GetActivityStreamsContent() vocab.ActivityStreamsContentProperty
	SetActivityStreamsContent(vocab.ActivityStreamsContentProperty)
}

WithContent represents an activity with ActivityStreamsContentProperty

type WithDiscoverable

type WithDiscoverable interface {
	GetTootDiscoverable() vocab.TootDiscoverableProperty
	SetTootDiscoverable(vocab.TootDiscoverableProperty)
}

WithDiscoverable represents an activity with TootDiscoverableProperty

type WithEndTime

type WithEndTime interface {
	GetActivityStreamsEndTime() vocab.ActivityStreamsEndTimeProperty
	SetActivityStreamsEndTime(vocab.ActivityStreamsEndTimeProperty)
}

WithEndTime represents an activity with the endTime property.

type WithEndpoints

type WithEndpoints interface {
	GetActivityStreamsEndpoints() vocab.ActivityStreamsEndpointsProperty
	SetActivityStreamsEndpoints(vocab.ActivityStreamsEndpointsProperty)
}

WithEndpoints represents a Person or profile with the endpoints property

type WithFeatured

type WithFeatured interface {
	GetTootFeatured() vocab.TootFeaturedProperty
	SetTootFeatured(vocab.TootFeaturedProperty)
}

WithFeatured represents an activity with TootFeaturedProperty

type WithFocalPoint added in v0.20.0

type WithFocalPoint interface {
	GetTootFocalPoint() vocab.TootFocalPointProperty
	SetTootFocalPoint(vocab.TootFocalPointProperty)
}

WithFocalPoint represents an object with TootFocalPointProperty.

type WithFollowers

type WithFollowers interface {
	GetActivityStreamsFollowers() vocab.ActivityStreamsFollowersProperty
	SetActivityStreamsFollowers(vocab.ActivityStreamsFollowersProperty)
}

WithFollowers represents an activity with ActivityStreamsFollowersProperty

type WithFollowing

type WithFollowing interface {
	GetActivityStreamsFollowing() vocab.ActivityStreamsFollowingProperty
	SetActivityStreamsFollowing(vocab.ActivityStreamsFollowingProperty)
}

WithFollowing represents an activity with ActivityStreamsFollowingProperty

type WithHidesCcPublicFromUnauthedWeb added in v0.20.0

type WithHidesCcPublicFromUnauthedWeb interface {
	GetGoToSocialHidesCcPublicFromUnauthedWeb() vocab.GoToSocialHidesCcPublicFromUnauthedWebProperty
	SetGoToSocialHidesCcPublicFromUnauthedWeb(vocab.GoToSocialHidesCcPublicFromUnauthedWebProperty)
}

WithHidesCcPublicFromUnauthedWeb represents a Person or profile with the hidesCcPublicFromUnauthedWeb property.

type WithHidesToPublicFromUnauthedWeb added in v0.20.0

type WithHidesToPublicFromUnauthedWeb interface {
	GetGoToSocialHidesToPublicFromUnauthedWeb() vocab.GoToSocialHidesToPublicFromUnauthedWebProperty
	SetGoToSocialHidesToPublicFromUnauthedWeb(vocab.GoToSocialHidesToPublicFromUnauthedWebProperty)
}

WithHidesToPublicFromUnauthedWeb represents a Person or profile with the hidesToPublicFromUnauthedWeb property.

type WithHref

type WithHref interface {
	GetActivityStreamsHref() vocab.ActivityStreamsHrefProperty
	SetActivityStreamsHref(vocab.ActivityStreamsHrefProperty)
}

WithHref represents an activity with ActivityStreamsHrefProperty

type WithIRI

type WithIRI interface {
	GetIRI() *url.URL
	IsIRI() bool
	SetIRI(*url.URL)
}

WithIRI represents an object (possibly) representable as an IRI.

type WithIcon

type WithIcon interface {
	GetActivityStreamsIcon() vocab.ActivityStreamsIconProperty
	SetActivityStreamsIcon(vocab.ActivityStreamsIconProperty)
}

WithIcon represents an activity with ActivityStreamsIconProperty

type WithImage

type WithImage interface {
	GetActivityStreamsImage() vocab.ActivityStreamsImageProperty
	SetActivityStreamsImage(vocab.ActivityStreamsImageProperty)
}

WithImage represents an activity with ActivityStreamsImageProperty

type WithInReplyTo

type WithInReplyTo interface {
	GetActivityStreamsInReplyTo() vocab.ActivityStreamsInReplyToProperty
	SetActivityStreamsInReplyTo(vocab.ActivityStreamsInReplyToProperty)
}

WithInReplyTo represents an activity with ActivityStreamsInReplyToProperty

type WithInbox

type WithInbox interface {
	GetActivityStreamsInbox() vocab.ActivityStreamsInboxProperty
	SetActivityStreamsInbox(vocab.ActivityStreamsInboxProperty)
}

WithInbox represents an activity with ActivityStreamsInboxProperty

type WithInstrument added in v0.20.0

type WithInstrument interface {
	GetActivityStreamsInstrument() vocab.ActivityStreamsInstrumentProperty
	SetActivityStreamsInstrument(vocab.ActivityStreamsInstrumentProperty)
}

WithInstrument represents an activity with ActivityStreamsInstrumentProperty

type WithInteractingObject added in v0.20.0

type WithInteractingObject interface {
	GetGoToSocialInteractingObject() vocab.GoToSocialInteractingObjectProperty
	SetGoToSocialInteractingObject(vocab.GoToSocialInteractingObjectProperty)
}

WithInteractingObject represents an activity or object with the InteractingObject property.

type WithInteractionPolicy

type WithInteractionPolicy interface {
	GetGoToSocialInteractionPolicy() vocab.GoToSocialInteractionPolicyProperty
	SetGoToSocialInteractionPolicy(vocab.GoToSocialInteractionPolicyProperty)
}

WithReplies represents an object with GoToSocialInteractionPolicy.

type WithInteractionTarget added in v0.20.0

type WithInteractionTarget interface {
	GetGoToSocialInteractionTarget() vocab.GoToSocialInteractionTargetProperty
	SetGoToSocialInteractionTarget(vocab.GoToSocialInteractionTargetProperty)
}

WithInteractionTarget represents an activity or object with the InteractionTarget property.

type WithItems

type WithItems interface {
	GetActivityStreamsItems() vocab.ActivityStreamsItemsProperty
	SetActivityStreamsItems(vocab.ActivityStreamsItemsProperty)
}

WithItems represents an activity with ActivityStreamsItemsProperty

type WithJSONLDId

type WithJSONLDId interface {
	GetJSONLDId() vocab.JSONLDIdProperty
	SetJSONLDId(vocab.JSONLDIdProperty)
}

WithJSONLDId represents an activity with JSONLDIdProperty.

type WithLikeAuthorization added in v0.20.0

type WithLikeAuthorization interface {
	GetGoToSocialLikeAuthorization() vocab.GoToSocialLikeAuthorizationProperty
	SetGoToSocialLikeAuthorization(vocab.GoToSocialLikeAuthorizationProperty)
}

WithLikeAuthorization represents a Likeable with the likeAuthorization property.

type WithManuallyApprovesFollowers

type WithManuallyApprovesFollowers interface {
	GetActivityStreamsManuallyApprovesFollowers() vocab.ActivityStreamsManuallyApprovesFollowersProperty
	SetActivityStreamsManuallyApprovesFollowers(vocab.ActivityStreamsManuallyApprovesFollowersProperty)
}

WithManuallyApprovesFollowers represents a Person or profile with the ManuallyApprovesFollowers property.

type WithMediaType

type WithMediaType interface {
	GetActivityStreamsMediaType() vocab.ActivityStreamsMediaTypeProperty
	SetActivityStreamsMediaType(vocab.ActivityStreamsMediaTypeProperty)
}

WithMediaType represents an activity with ActivityStreamsMediaTypeProperty

type WithMovedTo

type WithMovedTo interface {
	GetActivityStreamsMovedTo() vocab.ActivityStreamsMovedToProperty
	SetActivityStreamsMovedTo(vocab.ActivityStreamsMovedToProperty)
}

WithMovedTo represents an Object with ActivityStreamsMovedToProperty.

type WithName

type WithName interface {
	GetActivityStreamsName() vocab.ActivityStreamsNameProperty
	SetActivityStreamsName(vocab.ActivityStreamsNameProperty)
}

WithName represents an activity with ActivityStreamsNameProperty

type WithNext

type WithNext interface {
	GetActivityStreamsNext() vocab.ActivityStreamsNextProperty
	SetActivityStreamsNext(vocab.ActivityStreamsNextProperty)
}

WithNext represents an activity with ActivityStreamsNextProperty

type WithObject

type WithObject interface {
	GetActivityStreamsObject() vocab.ActivityStreamsObjectProperty
	SetActivityStreamsObject(vocab.ActivityStreamsObjectProperty)
}

WithObject represents an activity with ActivityStreamsObjectProperty

type WithOneOf

type WithOneOf interface {
	GetActivityStreamsOneOf() vocab.ActivityStreamsOneOfProperty
	SetActivityStreamsOneOf(vocab.ActivityStreamsOneOfProperty)
}

WithOneOf represents an activity with the oneOf property.

type WithOutbox

type WithOutbox interface {
	GetActivityStreamsOutbox() vocab.ActivityStreamsOutboxProperty
	SetActivityStreamsOutbox(vocab.ActivityStreamsOutboxProperty)
}

WithOutbox represents an activity with ActivityStreamsOutboxProperty

type WithPartOf

type WithPartOf interface {
	GetActivityStreamsPartOf() vocab.ActivityStreamsPartOfProperty
	SetActivityStreamsPartOf(vocab.ActivityStreamsPartOfProperty)
}

WithPartOf represents an activity with ActivityStreamsPartOfProperty

type WithPolicyRules

type WithPolicyRules interface {
	GetGoToSocialAutomaticApproval() vocab.GoToSocialAutomaticApprovalProperty
	GetGoToSocialManualApproval() vocab.GoToSocialManualApprovalProperty
	GetGoToSocialAlways() vocab.GoToSocialAlwaysProperty                     // Deprecated
	GetGoToSocialApprovalRequired() vocab.GoToSocialApprovalRequiredProperty // Deprecated
}

WithPolicyRules represents an activity with always and approvalRequired properties.

type WithPreferredUsername

type WithPreferredUsername interface {
	GetActivityStreamsPreferredUsername() vocab.ActivityStreamsPreferredUsernameProperty
	SetActivityStreamsPreferredUsername(vocab.ActivityStreamsPreferredUsernameProperty)
}

WithPreferredUsername represents an activity with ActivityStreamsPreferredUsernameProperty

type WithPublicKey

type WithPublicKey interface {
	GetW3IDSecurityV1PublicKey() vocab.W3IDSecurityV1PublicKeyProperty
	SetW3IDSecurityV1PublicKey(vocab.W3IDSecurityV1PublicKeyProperty)
}

WithPublicKey represents an activity with W3IDSecurityV1PublicKeyProperty

type WithPublished

type WithPublished interface {
	GetActivityStreamsPublished() vocab.ActivityStreamsPublishedProperty
	SetActivityStreamsPublished(vocab.ActivityStreamsPublishedProperty)
}

WithPublished represents an activity with ActivityStreamsPublishedProperty

type WithReplies

type WithReplies interface {
	GetActivityStreamsReplies() vocab.ActivityStreamsRepliesProperty
	SetActivityStreamsReplies(vocab.ActivityStreamsRepliesProperty)
}

WithReplies represents an activity with ActivityStreamsRepliesProperty

type WithReplyAuthorization added in v0.20.0

type WithReplyAuthorization interface {
	GetGoToSocialReplyAuthorization() vocab.GoToSocialReplyAuthorizationProperty
	SetGoToSocialReplyAuthorization(vocab.GoToSocialReplyAuthorizationProperty)
}

WithReplyAuthorization represents a statusable with the replyAuthorization property.

type WithResult

type WithResult interface {
	GetActivityStreamsResult() vocab.ActivityStreamsResultProperty
	SetActivityStreamsResult(vocab.ActivityStreamsResultProperty)
}

WithResult represents an activity or object with the result property.

type WithSensitive

type WithSensitive interface {
	GetActivityStreamsSensitive() vocab.ActivityStreamsSensitiveProperty
	SetActivityStreamsSensitive(vocab.ActivityStreamsSensitiveProperty)
}

WithSensitive represents an activity with ActivityStreamsSensitiveProperty

type WithSharedInbox

type WithSharedInbox interface {
	GetActivityStreamsSharedInbox() vocab.ActivityStreamsSharedInboxProperty
	SetActivityStreamsSharedInbox(vocab.ActivityStreamsSharedInboxProperty)
}

WithSharedInbox represents an activity with ActivityStreamsSharedInboxProperty

type WithSummary

type WithSummary interface {
	GetActivityStreamsSummary() vocab.ActivityStreamsSummaryProperty
	SetActivityStreamsSummary(vocab.ActivityStreamsSummaryProperty)
}

WithSummary represents an activity with ActivityStreamsSummaryProperty

type WithTag

type WithTag interface {
	GetActivityStreamsTag() vocab.ActivityStreamsTagProperty
	SetActivityStreamsTag(vocab.ActivityStreamsTagProperty)
}

WithTag represents an activity with ActivityStreamsTagProperty

type WithTarget

type WithTarget interface {
	GetActivityStreamsTarget() vocab.ActivityStreamsTargetProperty
	SetActivityStreamsTarget(vocab.ActivityStreamsTargetProperty)
}

WithTarget represents an activity with ActivityStreamsTargetProperty

type WithTo

type WithTo interface {
	GetActivityStreamsTo() vocab.ActivityStreamsToProperty
	SetActivityStreamsTo(vocab.ActivityStreamsToProperty)
}

WithTo represents an activity with ActivityStreamsToProperty

type WithType

type WithType interface {
	GetType() vocab.Type
}

WithType ...

type WithTypeName

type WithTypeName interface {
	GetTypeName() string
}

WithTypeName represents an activity with a type name

type WithURL

type WithURL interface {
	GetActivityStreamsUrl() vocab.ActivityStreamsUrlProperty
	SetActivityStreamsUrl(vocab.ActivityStreamsUrlProperty)
}

WithURL represents an activity with ActivityStreamsUrlProperty

type WithUpdated

type WithUpdated interface {
	GetActivityStreamsUpdated() vocab.ActivityStreamsUpdatedProperty
	SetActivityStreamsUpdated(vocab.ActivityStreamsUpdatedProperty)
}

WithUpdated represents an activity with ActivityStreamsUpdatedProperty

type WithValue

type WithValue interface {
	GetSchemaValue() vocab.SchemaValueProperty
	SetSchemaValue(vocab.SchemaValueProperty)
}

WithValue represents an activity with SchemaValueProperty

type WithVotersCount

type WithVotersCount interface {
	GetTootVotersCount() vocab.TootVotersCountProperty
	SetTootVotersCount(vocab.TootVotersCountProperty)
}

WithVotersCount represents an activity with the votersCount property.

Jump to

Keyboard shortcuts

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