Documentation ¶
Overview ¶
Package ap implements types that represent the ActivityPub vocabulary.
These types implement database/sql.Scanner and database/sql/driver.Valuer, allowing them to be stored in a SQL database as a JSON column.
Index ¶
Constants ¶
const Public = "https://www.w3.org/ns/activitystreams#Public"
Public is the special ActivityPub collection used for public addressing.
Variables ¶
var ErrInvalidActivity = errors.New("invalid activity")
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity struct { Context any `json:"@context,omitempty"` ID string `json:"id"` Type ActivityType `json:"type"` Actor string `json:"actor"` Object any `json:"object"` Target string `json:"target,omitempty"` To Audience `json:"to,omitempty"` CC Audience `json:"cc,omitempty"` Published *Time `json:"published,omitempty"` }
Activity represents an ActivityPub activity. Object can point to another Activity, an Object or a string.
func (*Activity) UnmarshalJSON ¶
type ActivityType ¶
type ActivityType string
const ( Create ActivityType = "Create" Follow ActivityType = "Follow" Accept ActivityType = "Accept" Undo ActivityType = "Undo" Delete ActivityType = "Delete" Announce ActivityType = "Announce" Update ActivityType = "Update" Like ActivityType = "Like" Dislike ActivityType = "Dislike" Move ActivityType = "Move" )
type Actor ¶
type Actor struct { Context any `json:"@context"` ID string `json:"id"` Type ActorType `json:"type"` Inbox string `json:"inbox"` Outbox string `json:"outbox"` Endpoints map[string]string `json:"endpoints,omitempty"` PreferredUsername string `json:"preferredUsername"` Name string `json:"name,omitempty"` Summary string `json:"summary,omitempty"` Followers string `json:"followers,omitempty"` PublicKey PublicKey `json:"publicKey"` Icon Array[Attachment] `json:"icon,omitempty"` Image *Attachment `json:"image,omitempty"` ManuallyApprovesFollowers bool `json:"manuallyApprovesFollowers"` AlsoKnownAs Audience `json:"alsoKnownAs,omitempty"` Published *Time `json:"published"` Updated *Time `json:"updated,omitempty"` MovedTo string `json:"movedTo,omitempty"` Suspended bool `json:"suspended,omitempty"` Attachment []Attachment `json:"attachment,omitempty"` }
Actor represents an ActivityPub actor.
type Array ¶
type Array[T any] []T
Array is an array or a single item.
func (Array[T]) MarshalJSON ¶
func (*Array[T]) UnmarshalJSON ¶
type Attachment ¶
type AttachmentType ¶
type AttachmentType string
const ( Image AttachmentType = "Image" PropertyValue AttachmentType = "PropertyValue" )
type Audience ¶
type Audience struct { data.OrderedMap[string, struct{}] }
Audience is an ordered, unique list of actor IDs.
func (Audience) MarshalJSON ¶
func (*Audience) UnmarshalJSON ¶
type Object ¶
type Object struct { Context any `json:"@context,omitempty"` ID string `json:"id"` Type ObjectType `json:"type"` AttributedTo string `json:"attributedTo,omitempty"` InReplyTo string `json:"inReplyTo,omitempty"` Content string `json:"content,omitempty"` Summary string `json:"summary,omitempty"` Sensitive bool `json:"sensitive,omitempty"` Name string `json:"name,omitempty"` Published Time `json:"published"` Updated *Time `json:"updated,omitempty"` To Audience `json:"to,omitempty"` CC Audience `json:"cc,omitempty"` Audience string `json:"audience,omitempty"` Tag Array[Tag] `json:"tag,omitempty"` Attachment []Attachment `json:"attachment,omitempty"` URL string `json:"url,omitempty"` // polls VotersCount int64 `json:"votersCount,omitempty"` OneOf []PollOption `json:"oneOf,omitempty"` AnyOf []PollOption `json:"anyOf,omitempty"` EndTime *Time `json:"endTime,omitempty"` Closed *Time `json:"closed,omitempty"` }
Object represents most ActivityPub objects. Actors are represented by Actor.
type ObjectType ¶
type ObjectType string
const ( Note ObjectType = "Note" Page ObjectType = "Page" Article ObjectType = "Article" Question ObjectType = "Question" )
type PollOption ¶
type RawActivity ¶
RawActivity is a serialized or serializable Activity
type Resolver ¶
type Resolver interface { ResolveID(ctx context.Context, key httpsig.Key, id string, flags ResolverFlag) (*Actor, error) Resolve(ctx context.Context, key httpsig.Key, host, name string, flags ResolverFlag) (*Actor, error) }
Resolver retrieves Actor objects given their ID.
type ResolverFlag ¶
type ResolverFlag uint
const ( // Offline disables fetching of remote actors and forces use of local or cached actors. Offline ResolverFlag = 1 // InstanceActor enables discovery of the "instance actor" instead of the regular actor discovery flow. InstanceActor = 2 )
type Tag ¶
type Tag struct { Type TagType `json:"type,omitempty"` Name string `json:"name,omitempty"` Href string `json:"href,omitempty"` Icon *Attachment `json:"icon,omitempty"` }