goap

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 8 Imported by: 0

README

GoAp

A Go library to more easily work with ActivityPub

Design goal

Provide an extendable and easy to use system for working with ActivityPub activities

Why?

Because the other existing solutions (used by fedbox and gotosocial) are both narrow in scope, only providing a subset of what AP is capable of, while simultaniously locking you into using them in a very specific way.

This library attempts to provide a more flexible interface to ActivityPub (and indirectly and technically jsonld too) by splitting it up into lots of small structs, one per attribute and extendable by implementing a parser func and an interface on the struct, then giving the parser func to the main parser of the library

Additionally the library provides structs that contain information that common ActivityPub servers send, such as Mastodon's Persons

Examples

TODO: Add examples here

Documentation

Index

Constants

View Source
const (
	KEY_ID    = "@id"    // Value of type string
	KEY_TYPE  = "@type"  // Value of type string slice / activitystreams object url slice
	KEY_VALUE = "@value" // Could be any type really
)
View Source
const (
	KEY_MASTO_DEVICES       = "http://joinmastodon.org/ns#devices"      // No idea what this is, but Masto includes it
	KEY_MASTO_DISCOVERABLE  = "http://joinmastodon.org/ns#discoverable" // iirc this is whether the object can be found by crawlers
	KEY_MASTO_FEATURED      = "http://joinmastodon.org/ns#featured"     // Users tagged? I think
	KEY_MASTO_FEATURED_TAGS = "http://joinmastodon.org/ns#featuredTags" // Hashtags included, I think
	KEY_MASTO_INDEXABLE     = "http://joinmastodon.org/ns#indexable"    // Is the object crawlable round 2
	KEY_MASTO_MEMORIAL      = "http://joinmastodon.org/ns#memorial"     // Account dead and disabled?

	KEY_MASTO_EMOJI = "http://joinmastodon.org/ns#Emoji" // Object is an emoji
)
View Source
const (
	KEY_W3_INBOX                 = "http://www.w3.org/ns/ldp#inbox"          // Where to send activities to
	KEY_W3_SECURITY_OWNER        = "https://w3id.org/security#owner"         // Owner of the public key
	KEY_W3_SECURITY_PUBLICKEY    = "https://w3id.org/security#publicKey"     // Public key of the account
	KEY_W3_SECURITY_PUBLICKEYPEM = "https://w3id.org/security#publicKeyPem"  // Pem content of the key
	KEY_W3_VCARD_ADDRESS         = "http://www.w3.org/2006/vcard/ns#Address" // Vcard address of an account
	KEY_W3_VCARD_BIRTHDAY        = "http://www.w3.org/2006/vcard/ns#bday"    // Vcard birthday of an account

	KEY_W3_SECURITY_KEY = "https://w3id.org/security#Key" // Object is a PublicKey
)
View Source
const (
	KEY_ACTIVITYSTREAMS_ACTOR             = "https://www.w3.org/ns/activitystreams#actor"
	KEY_ACTIVITYSTREAMS_ALSOKNOWNAS       = "https://www.w3.org/ns/activitystreams#alsoKnownAs"               // Lists of usernames?
	KEY_ACTIVITYSTREAMS_ATTACHMENTS       = "https://www.w3.org/ns/activitystreams#attachment"                // Attached elements like emotes and hashtags
	KEY_ACTIVITYSTREAMS_ATTRIBUTEDTO      = "https://www.w3.org/ns/activitystreams#attributedTo"              // Creator of object?
	KEY_ACTIVITYSTREAMS_CC                = "https://www.w3.org/ns/activitystreams#cc"                        // Urls also included in the object
	KEY_ACTIVITYSTREAMS_CONTENT           = "https://www.w3.org/ns/activitystreams#content"                   // (String) content of an object
	KEY_ACTIVITYSTREAMS_ENDPOINTS         = "https://www.w3.org/ns/activitystreams#endpoints"                 // list of assocciated endpoints
	KEY_ACTIVITYSTREAMS_FOLLOWERS         = "https://www.w3.org/ns/activitystreams#followers"                 // Who is following the account
	KEY_ACTIVITYSTREAMS_FOLLOWING         = "https://www.w3.org/ns/activitystreams#following"                 // Who is this account following
	KEY_ACTIVITYSTREAMS_HREF              = "https://www.w3.org/ns/activitystreams#href"                      // Some url with id
	KEY_ACTIVITYSTREAMS_ICON              = "https://www.w3.org/ns/activitystreams#icon"                      // User icon
	KEY_ACTIVITYSTREAMS_IMAGE_ATTRIBUTE   = "https://www.w3.org/ns/activitystreams#image"                     // Account banner
	KEY_ACTIVITYSTREAMS_MEDIATYPE         = "https://www.w3.org/ns/activitystreams#mediaType"                 // What type of media is this? Example image/jpeg
	KEY_ACTIVITYSTREAMS_NAME              = "https://www.w3.org/ns/activitystreams#name"                      // Name of the object
	KEY_ACTIVITYSTREAMS_OUTBOX            = "https://www.w3.org/ns/activitystreams#outbox"                    // Link to the account's outbox
	KEY_ACTIVITYSTREAMS_OBJECT            = "https://www.w3.org/ns/activitystreams#object"                    // Object url and sometimes value
	KEY_ACTIVITYSTREAMS_PREFFEREDUSERNAME = "https://www.w3.org/ns/activitystreams#preferredUsername"         // What the shown username is
	KEY_ACTIVITYSTREAMS_PUBLISHED         = "https://www.w3.org/ns/activitystreams#published"                 // When an object was created
	KEY_ACTIVITYSTREAMS_RESTRICTED_FOLLOW = "https://www.w3.org/ns/activitystreams#manuallyApprovesFollowers" // Does the account manually approve follow requests
	KEY_ACTIVITYSTREAMS_REPLIES           = "https://www.w3.org/ns/activitystreams#replies"                   // Object containing the replies. Should always be a Collection
	KEY_ACTIVITYSTREAMS_SHAREDINBOX       = "https://www.w3.org/ns/activitystreams#sharedInbox"               // Link to the shared inbox of the server
	KEY_ACTIVITYSTREAMS_SUMMARY           = "https://www.w3.org/ns/activitystreams#summary"                   // Summary of an account or the cw of a note
	KEY_ACTIVITYSTREAMS_SENSITIVE         = "https://www.w3.org/ns/activitystreams#sensitive"                 // Whether the content of the object is marked as sensitive
	KEY_ACTIVITYSTREAMS_TAG               = "https://www.w3.org/ns/activitystreams#tag"                       // A tag, usually hashtags included somewhere
	KEY_ACTIVITYSTREAMS_TO                = "https://www.w3.org/ns/activitystreams#to"                        // Urls to send an activity to
	KEY_ACTIVITYSTREAMS_URL               = "https://www.w3.org/ns/activitystreams#url"                       // Some url
	KEY_ACTIVITYSTREAMS_UPDATED           = "https://www.w3.org/ns/activitystreams#updated"                   // When the content was last updated
	KEY_ACTIVITYSTREAMS_INREPLYTO         = "https://www.w3.org/ns/activitystreams#inReplyTo"                 // What the object is replying to
	KEY_ACTIVITYSTREAMS_QUOTEURL          = "https://www.w3.org/ns/activitystreams#quoteUrl"                  // Url to the object being quoted

	KEY_ACTIVITYSTREAMS_FOLLOW         = "https://www.w3.org/ns/activitystreams#Follow"         // Object is an activity of type follow
	KEY_ACTIVITYSTREAMS_PERSON         = "https://www.w3.org/ns/activitystreams#Person"         // Object is of type Person
	KEY_ACTIVITYSTREAMS_CREATE         = "https://www.w3.org/ns/activitystreams#Create"         // Object is an activity of type Create
	KEY_ACTIVITYSTREAMS_COLLECTION     = "https://www.w3.org/ns/activitystreams#Collection"     // Object is a collection of things
	KEY_ACTIVITYSTREAMS_COLLECTIONPAGE = "https://www.w3.org/ns/activitystreams#CollectionPage" // Object is a page of a collection
	KEY_ACTIVITYSTREAMS_HASHTAG        = "https://www.w3.org/ns/activitystreams#Hashtag"        // Object is a hashtag
	KEY_ACTIVITYSTREAMS_LIKE           = "https://www.w3.org/ns/activitystreams#Like"           // Object is an activity of type like
	KEY_ACTIVITYSTREAMS_NOTE           = "https://www.w3.org/ns/activitystreams#Note"           // Object is of type Note
	KEY_ACTIVITYSTREAMS_IMAGE_TYPE     = "https://www.w3.org/ns/activitystreams#Image"          // Object is of type Image
	KEY_ACTIVITYSTREAMS_MENTION        = "https://www.w3.org/ns/activitystreams#Mention"        // Object is of type Mention

	// Collection things
	KEY_ACTIVITYSTREAMS_FIRST  = "https://www.w3.org/ns/activitystreams#first"  // First page in a collection
	KEY_ACTIVITYSTREAMS_ITEMS  = "https://www.w3.org/ns/activitystreams#items"  // Items in this collection page
	KEY_ACTIVITYSTREAMS_NEXT   = "https://www.w3.org/ns/activitystreams#next"   // Next page in a collection
	KEY_ACTIVITYSTREAMS_PARTOF = "https://www.w3.org/ns/activitystreams#partOf" // Collection the current page is a part of

	// Misc
	KEY_ACTIVITYSTREAMS_OAUTHAUTHORIZATION = "https://www.w3.org/ns/activitystreams#oauthAuthorizationEndpoint" // Endpoint url for oauth login?
	KEY_ACTIVITYSTREAMS_OAUTHTOKEN         = "https://www.w3.org/ns/activitystreams#oauthTokenEndpoint"         // Endpoint url for oauth token verification?
	KEY_ACTIVITYSTREAMS_UPLOADMEDIA        = "https://www.w3.org/ns/activitystreams#uploadMedia"                // Endpoint url to upload media to?
	KEY_ACTIVITYSTREAMS_PUBLIC             = "https://www.w3.org/ns/activitystreams#Public"                     // Note target
)
View Source
const (
	KEY_SCHEMA_VALUE = "http://schema.org#value" // The value for some field

	KEY_SCHEMA_PROPERTYVALUE = "http://schema.org#PropertyValue" // Object is of type property value
)
View Source
const (
	KEY_MISSKEY_MKSUMMARY   = "https://misskey-hub.net/ns#_misskey_summary" // Misskey specific formatted summary
	KEY_MISSKEY_ISCAT       = "https://misskey-hub.net/ns#isCat"            // Does the account identify as cat?
	KEY_MISSKEY_MKQUOTE     = "https://misskey-hub.net/ns#_misskey_quote"   // Misskey specific quote field
	KEY_FIREFISH_SPEAKASCAT = "https://joinfirefish.org/ns#speakAsCat"      // Does the account speak like a cat?
)
View Source
const (
	KEY_LITEPUB_CAPABILITIES      = "http://litepub.social/ns#capabilities"
	KEY_LITEPUB_OAUTHREGISTRATION = "http://litepub.social/ns#oauthRegistrationEndpoint"
)

No idea what either of those two do or are used for

View Source
const (
	KEY_OSTATUS_ATOMURI          = "http://ostatus.org#atomUri"          // Same as @id I think
	KEY_OSTATUS_CONVERSATION     = "http://ostatus.org#conversation"     // Similar to inReplyTo
	KEY_OSTATUS_INREPLYTOATOMURI = "http://ostatus.org#inReplyToAtomUri" // Same as InReplyTo, but with an atom uri as target
)

NOTE: ostatus.org seems to be redirecting to some weird scam(?) page

View Source
const (
	KEY_MYSTERIOUS_NOINDEX       = "_:noindex"
	KEY_MYSTERIOUS_BACKGROUNDURL = "_:backgroundUrl"
	KEY_MYSTERIOUS_FEATURED      = "_:featured"
)
View Source
const (
	KEY_FEDIBIRD_QUOTEURI = "http://fedibird.com/ns#quoteUri"
)
View Source
const (
	KEY_XMLSCHEMA_DATETIME = "http://www.w3.org/2001/XMLSchema#dateTime" // Type value for published value field
)

Variables

This section is empty.

Functions

func FindAttribute

func FindAttribute[T BaseApChain](object BaseApChain) (*T, bool)

Find an attribute in an ActivityPub object of the given type Returns a pointer to the found attribute and whether it found it 2nd parameter is true if the attribute was found, false otherwise

Types

type ASActorData

type ASActorData struct {
	FullIdType
}

func (*ASActorData) GetSelfOrBase

func (actor *ASActorData) GetSelfOrBase() (BaseApChain, bool)

func (*ASActorData) MarshalToMap

func (actor *ASActorData) MarshalToMap() map[string]any

type ASAlsoKnownAsData

type ASAlsoKnownAsData struct {
	Next BaseApChain
	Urls []string
}

func (*ASAlsoKnownAsData) GetSelfOrBase

func (cc *ASAlsoKnownAsData) GetSelfOrBase() (BaseApChain, bool)

func (*ASAlsoKnownAsData) MarshalToMap

func (cc *ASAlsoKnownAsData) MarshalToMap() map[string]any

type ASAttachmentsData

type ASAttachmentsData struct {
	Next        BaseApChain
	Attachments []Attachment
}

func (*ASAttachmentsData) GetSelfOrBase

func (attachmentsdata *ASAttachmentsData) GetSelfOrBase() (BaseApChain, bool)

func (*ASAttachmentsData) MarshalToMap

func (attachmentsdata *ASAttachmentsData) MarshalToMap() map[string]any

type ASAttributedToData

type ASAttributedToData struct {
	FullIdType
}

func (*ASAttributedToData) GetSelfOrBase

func (attributedtodata *ASAttributedToData) GetSelfOrBase() (BaseApChain, bool)

func (*ASAttributedToData) MarshalToMap

func (attributedtodata *ASAttributedToData) MarshalToMap() map[string]any

type ASCCData

type ASCCData struct {
	Next    BaseApChain
	Targets []string
}

func (*ASCCData) GetSelfOrBase

func (cc *ASCCData) GetSelfOrBase() (BaseApChain, bool)

func (*ASCCData) MarshalToMap

func (cc *ASCCData) MarshalToMap() map[string]any

type ASContentData

type ASContentData struct {
	Next    BaseApChain
	Content []ValueValue[string]
}

Content is an array of string value types due to some servers including the content in multiple languages or with different metadata attached

func (*ASContentData) GetSelfOrBase

func (contentdata *ASContentData) GetSelfOrBase() (BaseApChain, bool)

func (*ASContentData) MarshalToMap

func (contentdata *ASContentData) MarshalToMap() map[string]any

type ASEndpointsData

type ASEndpointsData struct {
	Next      BaseApChain
	Endpoints map[string]string
}

func (*ASEndpointsData) GetSelfOrBase

func (endpointsdata *ASEndpointsData) GetSelfOrBase() (BaseApChain, bool)

func (*ASEndpointsData) MarshalToMap

func (endpointsdata *ASEndpointsData) MarshalToMap() map[string]any

type ASFirstData added in v1.1.0

type ASFirstData struct {
	Next BaseApChain
	// Technically the object is decodable into BaseApChain as well
	// but Go doesn't like the potential recursive call
	// So uhh, you have to do it yourself
	Objects map[string]any
}

func (*ASFirstData) GetSelfOrBase added in v1.1.0

func (a *ASFirstData) GetSelfOrBase() (BaseApChain, bool)

func (*ASFirstData) MarshalToMap added in v1.1.0

func (a *ASFirstData) MarshalToMap() map[string]any

type ASFollowersData

type ASFollowersData struct {
	FullIdType
}

func (*ASFollowersData) GetSelfOrBase

func (attributedtodata *ASFollowersData) GetSelfOrBase() (BaseApChain, bool)

func (*ASFollowersData) MarshalToMap

func (attributedtodata *ASFollowersData) MarshalToMap() map[string]any

type ASFollowingData

type ASFollowingData struct {
	FullIdType
}

func (*ASFollowingData) GetSelfOrBase

func (attributedtodata *ASFollowingData) GetSelfOrBase() (BaseApChain, bool)

func (*ASFollowingData) MarshalToMap

func (attributedtodata *ASFollowingData) MarshalToMap() map[string]any

type ASHrefData

type ASHrefData struct {
	FullIdType
}

func (*ASHrefData) GetSelfOrBase

func (attributedtodata *ASHrefData) GetSelfOrBase() (BaseApChain, bool)

func (*ASHrefData) MarshalToMap

func (attributedtodata *ASHrefData) MarshalToMap() map[string]any

type ASIconData

type ASIconData struct {
	Next  BaseApChain
	Media Media
}

func (*ASIconData) GetSelfOrBase

func (icondata *ASIconData) GetSelfOrBase() (BaseApChain, bool)

func (*ASIconData) MarshalToMap

func (icondata *ASIconData) MarshalToMap() map[string]any

type ASImageData

type ASImageData struct {
	Next  BaseApChain
	Media Media
}

func (*ASImageData) GetSelfOrBase

func (icondata *ASImageData) GetSelfOrBase() (BaseApChain, bool)

func (*ASImageData) MarshalToMap

func (icondata *ASImageData) MarshalToMap() map[string]any

type ASInReplyTo added in v1.1.0

type ASInReplyTo struct {
	FullIdType
}

func (*ASInReplyTo) GetSelfOrBase added in v1.1.0

func (a *ASInReplyTo) GetSelfOrBase() (BaseApChain, bool)

func (*ASInReplyTo) MarshalToMap added in v1.1.0

func (a *ASInReplyTo) MarshalToMap() map[string]any

type ASItemsData added in v1.1.0

type ASItemsData struct {
	Next BaseApChain
	// Items are all AP objects, but can't preparse since Go doesn't like the potential recursion
	Items []map[string]any
}

func (*ASItemsData) GetSelfOrBase added in v1.1.0

func (a *ASItemsData) GetSelfOrBase() (BaseApChain, bool)

func (*ASItemsData) MarshalToMap added in v1.1.0

func (a *ASItemsData) MarshalToMap() map[string]any

type ASMediaTypeData

type ASMediaTypeData struct {
	FullValueType[string]
}

func (*ASMediaTypeData) GetSelfOrBase

func (mediatypedata *ASMediaTypeData) GetSelfOrBase() (BaseApChain, bool)

func (*ASMediaTypeData) MarshalToMap

func (mediatypedata *ASMediaTypeData) MarshalToMap() map[string]any

type ASNameData

type ASNameData struct {
	FullValueType[string]
}

func (*ASNameData) GetSelfOrBase

func (namedata *ASNameData) GetSelfOrBase() (BaseApChain, bool)

func (*ASNameData) MarshalToMap

func (namedata *ASNameData) MarshalToMap() map[string]any

type ASNextData added in v1.1.0

type ASNextData struct {
	FullIdType
}

func (*ASNextData) GetSelfOrBase added in v1.1.0

func (object *ASNextData) GetSelfOrBase() (BaseApChain, bool)

func (*ASNextData) MarshalToMap added in v1.1.0

func (object *ASNextData) MarshalToMap() map[string]any

type ASObjectData

type ASObjectData struct {
	Next BaseApChain
	// Unparsed objects. Please parse yourself. Go doesn't like the recursion if the parser for this attribute was calling Unmarshal
	Objects []map[string]any
}

func (*ASObjectData) GetSelfOrBase

func (object *ASObjectData) GetSelfOrBase() (BaseApChain, bool)

func (*ASObjectData) MarshalToMap

func (object *ASObjectData) MarshalToMap() map[string]any

type ASOutboxData

type ASOutboxData struct {
	FullIdType
}

func (*ASOutboxData) GetSelfOrBase

func (attributedtodata *ASOutboxData) GetSelfOrBase() (BaseApChain, bool)

func (*ASOutboxData) MarshalToMap

func (attributedtodata *ASOutboxData) MarshalToMap() map[string]any

type ASPartOfData added in v1.1.0

type ASPartOfData struct {
	FullIdType
}

func (*ASPartOfData) GetSelfOrBase added in v1.1.0

func (object *ASPartOfData) GetSelfOrBase() (BaseApChain, bool)

func (*ASPartOfData) MarshalToMap added in v1.1.0

func (object *ASPartOfData) MarshalToMap() map[string]any

type ASPreferredNameData

type ASPreferredNameData struct {
	FullValueType[string]
}

func (*ASPreferredNameData) GetSelfOrBase

func (namedata *ASPreferredNameData) GetSelfOrBase() (BaseApChain, bool)

func (*ASPreferredNameData) MarshalToMap

func (namedata *ASPreferredNameData) MarshalToMap() map[string]any

type ASPublishedData

type ASPublishedData struct {
	Next      BaseApChain
	Timestamp time.Time
}

func (*ASPublishedData) GetSelfOrBase

func (publisheddata *ASPublishedData) GetSelfOrBase() (BaseApChain, bool)

func (*ASPublishedData) MarshalToMap

func (publisheddata *ASPublishedData) MarshalToMap() map[string]any

type ASQuoteUrlData added in v1.1.0

type ASQuoteUrlData struct {
	FullValueType[string]
}

func (*ASQuoteUrlData) GetSelfOrBase added in v1.1.0

func (namedata *ASQuoteUrlData) GetSelfOrBase() (BaseApChain, bool)

func (*ASQuoteUrlData) MarshalToMap added in v1.1.0

func (namedata *ASQuoteUrlData) MarshalToMap() map[string]any

type ASRepliesData

type ASRepliesData struct {
	FullIdType
}

func (*ASRepliesData) GetSelfOrBase

func (object *ASRepliesData) GetSelfOrBase() (BaseApChain, bool)

func (*ASRepliesData) MarshalToMap

func (object *ASRepliesData) MarshalToMap() map[string]any

type ASRestrictedFollowData

type ASRestrictedFollowData struct {
	FullValueType[bool]
}

func (*ASRestrictedFollowData) GetSelfOrBase

func (namedata *ASRestrictedFollowData) GetSelfOrBase() (BaseApChain, bool)

func (*ASRestrictedFollowData) MarshalToMap

func (namedata *ASRestrictedFollowData) MarshalToMap() map[string]any

type ASSensitiveData

type ASSensitiveData struct {
	FullValueType[bool]
}

func (*ASSensitiveData) GetSelfOrBase

func (namedata *ASSensitiveData) GetSelfOrBase() (BaseApChain, bool)

func (*ASSensitiveData) MarshalToMap

func (namedata *ASSensitiveData) MarshalToMap() map[string]any

type ASSharedInboxData

type ASSharedInboxData struct {
	FullIdType
}

func (*ASSharedInboxData) GetSelfOrBase

func (object *ASSharedInboxData) GetSelfOrBase() (BaseApChain, bool)

func (*ASSharedInboxData) MarshalToMap

func (object *ASSharedInboxData) MarshalToMap() map[string]any

type ASSummaryData

type ASSummaryData struct {
	FullValueType[string]
}

func (*ASSummaryData) GetSelfOrBase

func (namedata *ASSummaryData) GetSelfOrBase() (BaseApChain, bool)

func (*ASSummaryData) MarshalToMap

func (namedata *ASSummaryData) MarshalToMap() map[string]any

type ASTagData

type ASTagData struct {
	Next BaseApChain
	Tags []Tag
}

func (*ASTagData) GetSelfOrBase

func (tagdata *ASTagData) GetSelfOrBase() (BaseApChain, bool)

func (*ASTagData) MarshalToMap

func (tagdata *ASTagData) MarshalToMap() map[string]any

type ASToData

type ASToData struct {
	Next    BaseApChain
	Targets []string
}

func (*ASToData) GetSelfOrBase

func (cc *ASToData) GetSelfOrBase() (BaseApChain, bool)

func (*ASToData) MarshalToMap

func (cc *ASToData) MarshalToMap() map[string]any

type ASUpdatedData

type ASUpdatedData struct {
	Next      BaseApChain
	Timestamp time.Time
}

func (*ASUpdatedData) GetSelfOrBase

func (publisheddata *ASUpdatedData) GetSelfOrBase() (BaseApChain, bool)

func (*ASUpdatedData) MarshalToMap

func (publisheddata *ASUpdatedData) MarshalToMap() map[string]any

type ASUrlData

type ASUrlData struct {
	FullIdType
}

func (*ASUrlData) GetSelfOrBase

func (object *ASUrlData) GetSelfOrBase() (BaseApChain, bool)

func (*ASUrlData) MarshalToMap

func (object *ASUrlData) MarshalToMap() map[string]any

type Attachment

type Attachment struct {
	Type  string
	Value string
	Name  string
}

func ParseAttachment

func ParseAttachment(raw map[string]any) (*Attachment, error)

func (Attachment) Marshal

func (a Attachment) Marshal() map[string]any

type BadFieldArrayLengthError

type BadFieldArrayLengthError struct {
	FieldName   string
	ExpectedLen int
	ActualLen   int
}

func (BadFieldArrayLengthError) Error

func (b BadFieldArrayLengthError) Error() string

type BadFieldValueError

type BadFieldValueError[T any] struct {
	FieldName string
	RawValue  any
	Expected  T
}

Expected is a string representation of the expected type

func (BadFieldValueError[T]) Error

func (b BadFieldValueError[T]) Error() string

type BaseApChain

type BaseApChain interface {
	// Get the next "object" in the chain (or self if last element in chain)
	// Though preferably the last element should always be a BaseObject
	// The 2nd parameter indicates whether the returned value is different from the one the function is called on
	// So true => Is a different object, false => is self
	GetSelfOrBase() (BaseApChain, bool)
	// Convert the chain to a map
	// Should include the rest of the chain (extend the map the underlying object returns)
	MarshalToMap() map[string]any
}

Interface for every struct that can be part of an ActivityPub object

func ParseASActorData

func ParseASActorData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASAlsoKnownAsData

func ParseASAlsoKnownAsData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASAttachmentsData

func ParseASAttachmentsData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASAttributedToData

func ParseASAttributedToData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASCCData

func ParseASCCData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASContentData

func ParseASContentData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASEndpointsData

func ParseASEndpointsData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASFirstData added in v1.1.0

func ParseASFirstData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASFollowersData

func ParseASFollowersData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASFollowingData

func ParseASFollowingData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASHrefData

func ParseASHrefData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASIconData

func ParseASIconData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASImageData

func ParseASImageData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASInReplyToData added in v1.1.0

func ParseASInReplyToData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASItemsData added in v1.1.0

func ParseASItemsData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASMediaTypeData

func ParseASMediaTypeData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASNameData

func ParseASNameData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASNextData added in v1.1.0

func ParseASNextData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASObjectData

func ParseASObjectData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASOutboxData

func ParseASOutboxData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASPartOfData added in v1.1.0

func ParseASPartOfData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASPreferredNameData

func ParseASPreferredNameData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASPublishedData

func ParseASPublishedData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASQuoteUrlData added in v1.1.0

func ParseASQuoteUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASRepliesData

func ParseASRepliesData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASRestrictedData

func ParseASRestrictedData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASSensitiveData

func ParseASSensitiveData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASSharedInboxData

func ParseASSharedInboxData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASSummaryData

func ParseASSummaryData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASTagData

func ParseASTagData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASToData

func ParseASToData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASUpdatedData

func ParseASUpdatedData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseASUrlData

func ParseASUrlData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseFFSpeakAsCatData

func ParseFFSpeakAsCatData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseFedibirdQuoteUriData added in v1.1.0

func ParseFedibirdQuoteUriData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseLitepubCapabilitiesData

func ParseLitepubCapabilitiesData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseLitepubOauthRegistrationEndpointData

func ParseLitepubOauthRegistrationEndpointData(
	raw map[string]any,
	next BaseApChain,
) (BaseApChain, error)

func ParseMKIsCatData

func ParseMKIsCatData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMKQuoteData added in v1.1.0

func ParseMKQuoteData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMKSummaryData

func ParseMKSummaryData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoDevicesData

func ParseMastoDevicesData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoDiscoverableData

func ParseMastoDiscoverableData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoFeaturedData

func ParseMastoFeaturedData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoFeaturedTagsData

func ParseMastoFeaturedTagsData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoIndexableData

func ParseMastoIndexableData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseMastoMemorialData

func ParseMastoMemorialData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseOstatusAtomUriData

func ParseOstatusAtomUriData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseOstatusConversationData

func ParseOstatusConversationData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseOstatusInReplyToAtomUriData added in v1.1.0

func ParseOstatusInReplyToAtomUriData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseSchemaValueData

func ParseSchemaValueData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseUDIdData

func ParseUDIdData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseUDTypeData

func ParseUDTypeData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3InboxData

func ParseW3InboxData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3SecurityOwnerData

func ParseW3SecurityOwnerData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3SecurityPublicKeyData

func ParseW3SecurityPublicKeyData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3SecurityPublicKeyPemData

func ParseW3SecurityPublicKeyPemData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3VcardAddressData

func ParseW3VcardAddressData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func ParseW3VcardBirthdayData

func ParseW3VcardBirthdayData(raw map[string]any, next BaseApChain) (BaseApChain, error)

func Unmarshal

func Unmarshal(
	raw []byte,
	ldOptions *ld.JsonLdOptions,
	processor *ld.JsonLdProcessor,
	extraParsers ...UnmarshalFunc,
) (BaseApChain, []error)

Unmarshal raw data into an Activitypub object in the form of a recursive BaseApChain Each element corresponds to one attribute the object contained If ldOptions or processor are nil, the following defaults are used: - ldOptions: `ld.NewJsonLdOptions("")` - processor: `ld.NewJsonLdProcessor()` Returns an ActivityPub object and a list of errors produced by the parser functions Not each function has to produce an error. Those will have nil as error value Those errors (or nils) come in the order of the parser functions which can be inspected in the `allInternalParsersExceptBase` internal variable

func UnmarshalPreprocessed

func UnmarshalPreprocessed(
	raw map[string]any,
	extraParsers ...UnmarshalFunc,
) (BaseApChain, []error)

Unmarshal a preproccessed object. Preproccessed meaning being first parsed as json and then expanded by json-gold Otherwise the same as Unmarshal

type EmptyBaseObject

type EmptyBaseObject struct{}

func (*EmptyBaseObject) GetSelfOrBase

func (e *EmptyBaseObject) GetSelfOrBase() (BaseApChain, bool)

func (*EmptyBaseObject) MarshalToMap

func (e *EmptyBaseObject) MarshalToMap() map[string]any

type FFSpeakAsCatData

type FFSpeakAsCatData struct {
	FullValueType[bool]
}

func (*FFSpeakAsCatData) GetSelfOrBase

func (iscatdata *FFSpeakAsCatData) GetSelfOrBase() (BaseApChain, bool)

func (*FFSpeakAsCatData) MarshalToMap

func (iscatdata *FFSpeakAsCatData) MarshalToMap() map[string]any

type FedibirdQuoteUriData added in v1.1.0

type FedibirdQuoteUriData struct {
	FullValueType[string]
}

func (*FedibirdQuoteUriData) GetSelfOrBase added in v1.1.0

func (f *FedibirdQuoteUriData) GetSelfOrBase() (BaseApChain, bool)

func (*FedibirdQuoteUriData) MarshalToMap added in v1.1.0

func (f *FedibirdQuoteUriData) MarshalToMap() map[string]any

type FullIdType

type FullIdType struct {
	Next BaseApChain
	Id   string
}

Helper type for parsing attributes where the value (after expansion) is of the following form ```json [

{
  "@id": "some url here"
}

] ```

func ParseIdTypeWithName

func ParseIdTypeWithName(m map[string]any, b BaseApChain, name string) (*FullIdType, error)

func (*FullIdType) GetSelfOrBase

func (idtype *FullIdType) GetSelfOrBase() (BaseApChain, bool)

func (*FullIdType) MarshalToMapWithName

func (idtype *FullIdType) MarshalToMapWithName(name string) map[string]any

type FullValueType

type FullValueType[T any] struct {
	Next  BaseApChain
	Value ValueValue[T]
}

func ParseValueTypeWithName

func ParseValueTypeWithName[T any](
	m map[string]any,
	b BaseApChain,
	name string,
) (*FullValueType[T], error)

func (*FullValueType[T]) GetSelfOrBase

func (v *FullValueType[T]) GetSelfOrBase() (BaseApChain, bool)

func (*FullValueType[T]) MarshalToMapWithName

func (v *FullValueType[T]) MarshalToMapWithName(name string) map[string]any

type IdValue

type IdValue struct {
	Id string
}

func ParseIdValue

func ParseIdValue(r map[string]any) (*IdValue, error)

func (IdValue) Marshal

func (i IdValue) Marshal() map[string]any

type LitepubCapabilitiesData

type LitepubCapabilitiesData struct {
	Next         BaseApChain
	Capabilities []map[string]any // I have no idea what the data inside there looks like
}

func (*LitepubCapabilitiesData) GetSelfOrBase

func (capabilitiesdata *LitepubCapabilitiesData) GetSelfOrBase() (BaseApChain, bool)

func (*LitepubCapabilitiesData) MarshalToMap

func (capabilitiesdata *LitepubCapabilitiesData) MarshalToMap() map[string]any

type LitepubOauthRegistrationEndpointData

type LitepubOauthRegistrationEndpointData struct {
	FullIdType
}

func (*LitepubOauthRegistrationEndpointData) GetSelfOrBase

func (oauthregistrationendpointdata *LitepubOauthRegistrationEndpointData) GetSelfOrBase() (BaseApChain, bool)

func (*LitepubOauthRegistrationEndpointData) MarshalToMap

func (oauthregistrationendpointdata *LitepubOauthRegistrationEndpointData) MarshalToMap() map[string]any

type MKIsCatData

type MKIsCatData struct {
	FullValueType[bool]
}

func (*MKIsCatData) GetSelfOrBase

func (iscatdata *MKIsCatData) GetSelfOrBase() (BaseApChain, bool)

func (*MKIsCatData) MarshalToMap

func (iscatdata *MKIsCatData) MarshalToMap() map[string]any

type MKQuoteData added in v1.1.0

type MKQuoteData struct {
	FullValueType[string]
}

func (*MKQuoteData) GetSelfOrBase added in v1.1.0

func (misskeysummarydata *MKQuoteData) GetSelfOrBase() (BaseApChain, bool)

func (*MKQuoteData) MarshalToMap added in v1.1.0

func (misskeysummarydata *MKQuoteData) MarshalToMap() map[string]any

type MKSummaryData

type MKSummaryData struct {
	FullValueType[string]
}

NOTE: Different to ASSummaryData Misskey summary is the raw text without formatting applied while the Activitystreams summary already contains the preformatted summary

func (*MKSummaryData) GetSelfOrBase

func (misskeysummarydata *MKSummaryData) GetSelfOrBase() (BaseApChain, bool)

func (*MKSummaryData) MarshalToMap

func (misskeysummarydata *MKSummaryData) MarshalToMap() map[string]any

type MastoDevicesData

type MastoDevicesData struct {
	FullIdType
}

func (*MastoDevicesData) GetSelfOrBase

func (actor *MastoDevicesData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoDevicesData) MarshalToMap

func (actor *MastoDevicesData) MarshalToMap() map[string]any

type MastoDiscoverableData

type MastoDiscoverableData struct {
	FullValueType[bool]
}

func (*MastoDiscoverableData) GetSelfOrBase

func (namedata *MastoDiscoverableData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoDiscoverableData) MarshalToMap

func (namedata *MastoDiscoverableData) MarshalToMap() map[string]any

type MastoFeaturedData

type MastoFeaturedData struct {
	FullIdType
}

func (*MastoFeaturedData) GetSelfOrBase

func (actor *MastoFeaturedData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoFeaturedData) MarshalToMap

func (actor *MastoFeaturedData) MarshalToMap() map[string]any

type MastoFeaturedTagsData

type MastoFeaturedTagsData struct {
	FullIdType
}

func (*MastoFeaturedTagsData) GetSelfOrBase

func (actor *MastoFeaturedTagsData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoFeaturedTagsData) MarshalToMap

func (actor *MastoFeaturedTagsData) MarshalToMap() map[string]any

type MastoIndexableData

type MastoIndexableData struct {
	FullValueType[bool]
}

func (*MastoIndexableData) GetSelfOrBase

func (namedata *MastoIndexableData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoIndexableData) MarshalToMap

func (namedata *MastoIndexableData) MarshalToMap() map[string]any

type MastoMemorialData

type MastoMemorialData struct {
	FullValueType[bool]
}

func (*MastoMemorialData) GetSelfOrBase

func (namedata *MastoMemorialData) GetSelfOrBase() (BaseApChain, bool)

func (*MastoMemorialData) MarshalToMap

func (namedata *MastoMemorialData) MarshalToMap() map[string]any

type Media

type Media struct {
	Type      string
	Url       string
	MediaType *string
	Sensitive *bool
}

func ParseMedia

func ParseMedia(raw map[string]any) (*Media, error)

func (Media) Marshal

func (m Media) Marshal() map[string]any

type NoRequiredFieldError

type NoRequiredFieldError struct {
	FieldName string
}

func (NoRequiredFieldError) Error

func (n NoRequiredFieldError) Error() string

type NoRequiredSubFieldError

type NoRequiredSubFieldError struct {
	FieldName string
	Subfield  string
}

func (NoRequiredSubFieldError) Error

func (n NoRequiredSubFieldError) Error() string

type NotImplementedError

type NotImplementedError struct{}

func (NotImplementedError) Error

func (n NotImplementedError) Error() string

type OstatusAtomUriData

type OstatusAtomUriData struct {
	FullValueType[string]
}

func (*OstatusAtomUriData) GetSelfOrBase

func (atomurivalue *OstatusAtomUriData) GetSelfOrBase() (BaseApChain, bool)

func (*OstatusAtomUriData) MarshalToMap

func (atomurivalue *OstatusAtomUriData) MarshalToMap() map[string]any

type OstatusConversationData

type OstatusConversationData struct {
	FullValueType[string]
}

func (*OstatusConversationData) GetSelfOrBase

func (atomurivalue *OstatusConversationData) GetSelfOrBase() (BaseApChain, bool)

func (*OstatusConversationData) MarshalToMap

func (atomurivalue *OstatusConversationData) MarshalToMap() map[string]any

type OstatusReplyToAtomUriData added in v1.1.0

type OstatusReplyToAtomUriData struct {
	FullValueType[string]
}

func (*OstatusReplyToAtomUriData) GetSelfOrBase added in v1.1.0

func (a *OstatusReplyToAtomUriData) GetSelfOrBase() (BaseApChain, bool)

func (*OstatusReplyToAtomUriData) MarshalToMap added in v1.1.0

func (a *OstatusReplyToAtomUriData) MarshalToMap() map[string]any

type PublicKey

type PublicKey struct {
	Id    string
	Owner string
	Pem   string
}

func ParsePublicKey

func ParsePublicKey(_ map[string]any) (PublicKey, error)

func (PublicKey) Marshal

func (p PublicKey) Marshal() map[string]any

type SchemaValueData

type SchemaValueData struct {
	FullValueType[string]
}

func (*SchemaValueData) GetSelfOrBase

func (namedata *SchemaValueData) GetSelfOrBase() (BaseApChain, bool)

func (*SchemaValueData) MarshalToMap

func (namedata *SchemaValueData) MarshalToMap() map[string]any

type Tag

type Tag interface {
	Marshal() map[string]any
	// contains filtered or unexported methods
}

go-sumtype:decl TagSum

func ParseTag

func ParseTag(raw map[string]any) (Tag, error)

type TagEmoji

type TagEmoji struct {
	Id          string
	Icon        Media
	Name        string
	LastUpdated time.Time
}

func (TagEmoji) Marshal

func (t TagEmoji) Marshal() map[string]any

type TagHashtag

type TagHashtag struct {
	Url  string
	Name string
}

func (TagHashtag) Marshal

func (t TagHashtag) Marshal() map[string]any

type TagMention

type TagMention struct {
	TargetId   string
	TargetName string
}

func (TagMention) Marshal

func (t TagMention) Marshal() map[string]any

type UDIdData

type UDIdData struct {
	Next BaseApChain
	Id   string
}

func (*UDIdData) GetSelfOrBase

func (u *UDIdData) GetSelfOrBase() (BaseApChain, bool)

func (*UDIdData) MarshalToMap

func (b *UDIdData) MarshalToMap() map[string]any

type UDTypeData

type UDTypeData struct {
	Next BaseApChain
	Type string
}

func (*UDTypeData) GetSelfOrBase

func (u *UDTypeData) GetSelfOrBase() (BaseApChain, bool)

func (*UDTypeData) MarshalToMap

func (u *UDTypeData) MarshalToMap() map[string]any

type UnknownTagType

type UnknownTagType struct {
	TagType string
}

func (UnknownTagType) Error

func (u UnknownTagType) Error() string

type UnmarshalFunc

type UnmarshalFunc func(map[string]any, BaseApChain) (BaseApChain, error)

Func used to add parsers for other attributes not yet included in the library It is expected that, on success, the function removes its key from the raw map

type ValueValue

type ValueValue[T any] struct {
	Type        *string
	Value       T
	OtherThings map[string]any
}

func ParseValueValue

func ParseValueValue[T any](raw map[string]any) (*ValueValue[T], error)

func (ValueValue[T]) Marshal

func (v ValueValue[T]) Marshal() map[string]any

type W3InboxData

type W3InboxData struct {
	FullIdType
}

func (*W3InboxData) GetSelfOrBase

func (actor *W3InboxData) GetSelfOrBase() (BaseApChain, bool)

func (*W3InboxData) MarshalToMap

func (actor *W3InboxData) MarshalToMap() map[string]any

type W3SecurityOwnerData

type W3SecurityOwnerData struct {
	FullIdType
}

func (*W3SecurityOwnerData) GetSelfOrBase

func (actor *W3SecurityOwnerData) GetSelfOrBase() (BaseApChain, bool)

func (*W3SecurityOwnerData) MarshalToMap

func (actor *W3SecurityOwnerData) MarshalToMap() map[string]any

type W3SecurityPublicKeyData

type W3SecurityPublicKeyData struct {
	Next  BaseApChain
	Id    string
	Owner string
	Key   string
}

TODO: Handle case with multiple public keys (if allowed, idk if it is)

func (*W3SecurityPublicKeyData) GetSelfOrBase

func (publickeydata *W3SecurityPublicKeyData) GetSelfOrBase() (BaseApChain, bool)

func (*W3SecurityPublicKeyData) MarshalToMap

func (publickeydata *W3SecurityPublicKeyData) MarshalToMap() map[string]any

type W3SecurityPublicKeyPemData

type W3SecurityPublicKeyPemData struct {
	FullValueType[string]
}

func (*W3SecurityPublicKeyPemData) GetSelfOrBase

func (namedata *W3SecurityPublicKeyPemData) GetSelfOrBase() (BaseApChain, bool)

func (*W3SecurityPublicKeyPemData) MarshalToMap

func (namedata *W3SecurityPublicKeyPemData) MarshalToMap() map[string]any

type W3VcardAddressData

type W3VcardAddressData struct {
	FullValueType[string]
}

func (*W3VcardAddressData) GetSelfOrBase

func (misskeysummarydata *W3VcardAddressData) GetSelfOrBase() (BaseApChain, bool)

func (*W3VcardAddressData) MarshalToMap

func (misskeysummarydata *W3VcardAddressData) MarshalToMap() map[string]any

type W3VcardBirthdayData

type W3VcardBirthdayData struct {
	FullValueType[string]
}

func (*W3VcardBirthdayData) GetSelfOrBase

func (misskeysummarydata *W3VcardBirthdayData) GetSelfOrBase() (BaseApChain, bool)

func (*W3VcardBirthdayData) MarshalToMap

func (misskeysummarydata *W3VcardBirthdayData) MarshalToMap() map[string]any

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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