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 ¶
View Source
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 // GroupActor makes [Resolver] prefer the first [Group] actor in the WebFinger response. GroupActor = 4 )
View Source
const Public = "https://www.w3.org/ns/activitystreams#Public"
Public is the special ActivityPub collection used for public addressing.
Variables ¶
View Source
var ( ErrInvalidActivity = errors.New("invalid activity") ErrUnsupportedActivity = errors.New("unsupported 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,omitzero"`
}
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 ( MaxActivityDepth = 3 Create ActivityType = "Create" Follow ActivityType = "Follow" Accept ActivityType = "Accept" Reject ActivityType = "Reject" Undo ActivityType = "Undo" Delete ActivityType = "Delete" Announce ActivityType = "Announce" Update ActivityType = "Update" Move ActivityType = "Move" Like ActivityType = "Like" Dislike ActivityType = "Dislike" EmojiReact ActivityType = "EmojiReact" Add ActivityType = "Add" Remove ActivityType = "Remove" )
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,omitzero"`
Updated Time `json:"updated,omitzero"`
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,omitzero"`
Updated Time `json:"updated,omitzero"`
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,omitzero"`
Closed Time `json:"closed,omitzero"`
}
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" Tombstone ObjectType = "Tombstone" )
type PollOption ¶
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)
Get(ctx context.Context, key httpsig.Key, url string) (*http.Response, error)
}
type ResolverFlag ¶
type ResolverFlag uint
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"`
}
Click to show internal directories.
Click to hide internal directories.