activitypub

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: MIT Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActivityFollow   = "Follow"
	ActivityAccept   = "Accept"
	ActivityReject   = "Reject"
	ActivityUndo     = "Undo"
	ActivityCreate   = "Create"
	ActivityUpdate   = "Update"
	ActivityAnnounce = "Announce"
	ActivityDelete   = "Delete"

	AutoAcceptNone   = "none"
	AutoAcceptAll    = "all"
	AutoAcceptMutual = "mutual"
)
View Source
const (
	ContextActivityStreams = "https://www.w3.org/ns/activitystreams"
	ContextSecurity        = "https://w3id.org/security/v1"
	ContextOCI             = "https://opencontainers.org/ns/distribution"

	KeyContext = "@context"
	KeyType    = "type"
	KeyObject  = "object"
	KeyActor   = "actor"
	KeyID      = "id"

	TypeOCIManifest = "OCIManifest"
	TypeOCITag      = "OCITag"
	TypeOCIBlob     = "OCIBlob"
	TypeApplication = "Application"
	TypePerson      = "Person"

	TypeOrderedCollection     = "OrderedCollection"
	TypeOrderedCollectionPage = "OrderedCollectionPage"

	KeyOCIRepository = "ociRepository"
	KeyOCIDigest     = "ociDigest"
	KeyOCITag        = "ociTag"
	KeyOCIMediaType  = "ociMediaType"
	KeyOCISize       = "ociSize"
	KeyOCIContent    = "ociContent"
	KeyOCIEndpoint   = "ociEndpoint"

	MediaTypeActivityJSON = "application/activity+json"
	PEMTypePublicKey      = "PUBLIC KEY"
	WebFingerRelSelf      = "self"
)
View Source
const PublicCollection = "https://www.w3.org/ns/activitystreams#Public"

PublicCollection is the special ActivityStreams address for public content.

Variables

This section is empty.

Functions

func ActorAlias added in v0.0.17

func ActorAlias(actor *Actor) string

ActorAlias returns the account domain for display. Uses OCINamespace (account domain) when available for split-domain setups, otherwise falls back to the actor URL hostname.

func BaseContext added in v0.0.27

func BaseContext() []string

BaseContext is the standard AS2 + Security pair used by adapters that don't extend the vocabulary with backend-specific terms.

func DecodeContent

func DecodeContent(encoded string) ([]byte, error)

DecodeContent decodes base64 manifest content from AP transport.

func DeliverActivity

func DeliverActivity(ctx context.Context, inboxURL string, activityJSON []byte, identity *Identity) error

func DomainFromActorURL added in v0.0.17

func DomainFromActorURL(actorURL string) string

DomainFromActorURL extracts the hostname from an actor URL.

func EncodeContent

func EncodeContent(data []byte) string

EncodeContent base64-encodes manifest bytes for AP transport.

func EndpointFromActorURL

func EndpointFromActorURL(actorURL string) string

EndpointFromActorURL extracts the scheme+host base URL from an actor URL. It returns the original string unchanged when parsing fails.

func ExtractKeyID

func ExtractKeyID(req *http.Request) (string, error)

func NowRFC3339 added in v0.0.27

func NowRFC3339() string

func ResolveFollowTarget

func ResolveFollowTarget(ctx context.Context, input string) (string, error)

ResolveFollowTarget resolves a domain, handle, or actor URL to an actor URL.

func SendAccept

func SendAccept(ctx context.Context, identity *Identity, followerActorURL string, enqueue EnqueueFunc) error

SendAccept builds and delivers an Accept(Follow) activity to the follower's inbox. The caller is responsible for any DB state transitions (e.g. AcceptFollowRequest) before calling this function.

func SendFollow added in v0.0.7

func SendFollow(ctx context.Context, identity *Identity, targetActorURL string, enqueue EnqueueFunc) (string, error)

SendFollow builds and delivers a Follow activity to the target actor's inbox. Returns the actor's canonical ID. The caller is responsible for recording the outgoing follow and peer in the database.

func SendReject

func SendReject(ctx context.Context, identity *Identity, followerActorURL string, enqueue EnqueueFunc) error

SendReject builds and delivers a Reject(Follow) activity to the follower's inbox. The caller is responsible for any DB state transitions (e.g. RejectFollowRequest) before calling this function.

func SendUndo

func SendUndo(ctx context.Context, identity *Identity, peerActorURL string, enqueue EnqueueFunc) error

SendUndo builds and delivers an Undo(Follow) activity to the peer. Best-effort: returns an error but the caller should still proceed with the local cleanup.

func SetAllowInsecureHTTP

func SetAllowInsecureHTTP(v bool)

SetAllowInsecureHTTP enables or disables insecure HTTP federation URLs.

func SignRequest

func SignRequest(req *http.Request, keyID string, privKey crypto.PrivateKey, body []byte) error

func StopDefaultWebFingerClient added in v0.0.9

func StopDefaultWebFingerClient()

func VerifyRequest

func VerifyRequest(req *http.Request, pubKeyPEM string, body []byte, sigCache *SignatureCache) error

Types

type APPublisher

type APPublisher struct {
	// contains filtered or unexported fields
}

func NewAPPublisher

func NewAPPublisher(identity *Identity, db PublisherRepository, endpoint string, excludedRepos []string, logger *slog.Logger) *APPublisher

func (*APPublisher) ActorCache

func (p *APPublisher) ActorCache() *ActorCache

func (*APPublisher) Publish added in v0.0.27

func (p *APPublisher) Publish(ctx context.Context, activityType string, object any) error

Publish is used by non-OCI backends (npm/cargo/pypi) which carry no tag context.

func (*APPublisher) PublishBlobRef

func (p *APPublisher) PublishBlobRef(ctx context.Context, digest string, size int64) error

func (*APPublisher) PublishManifest

func (p *APPublisher) PublishManifest(ctx context.Context, repo, tag, digest, mediaType string, size int64, content []byte, subjectDigest *string) error

func (*APPublisher) PublishManifestDelete added in v0.0.29

func (p *APPublisher) PublishManifestDelete(ctx context.Context, repo, digest string) error

func (*APPublisher) PublishTag

func (p *APPublisher) PublishTag(ctx context.Context, repo, tag, digest string) error

func (*APPublisher) PublishTagDelete added in v0.0.29

func (p *APPublisher) PublishTagDelete(ctx context.Context, repo, tag string) error

func (*APPublisher) SetNotifyFunc

func (p *APPublisher) SetNotifyFunc(fn func())

func (*APPublisher) Stop

func (p *APPublisher) Stop()

Stop releases background resources (actor cache eviction).

func (*APPublisher) WithdrawRepo added in v0.0.37

func (p *APPublisher) WithdrawRepo(ctx context.Context, repo string, tags []string, manifestDigests []string) error

type APResolver

type APResolver struct {
	// contains filtered or unexported fields
}

func NewAPResolver

func NewAPResolver(db ResolverRepository, logger *slog.Logger) *APResolver

func (*APResolver) FindBlobPeers

func (r *APResolver) FindBlobPeers(ctx context.Context, digest string) ([]oci.BlobPeer, error)

type ActivityEnqueuer added in v0.0.5

type ActivityEnqueuer interface {
	Enqueue(task InboxTask) bool
}

ActivityEnqueuer pushes validated activities for async processing.

type Actor

type Actor struct {
	Context           []any             `json:"@context"`
	Type              string            `json:"type"`
	ID                string            `json:"id"`
	Name              string            `json:"name"`
	PreferredUsername string            `json:"preferredUsername"`
	Inbox             string            `json:"inbox"`
	Outbox            string            `json:"outbox"`
	Followers         string            `json:"followers"`
	Following         string            `json:"following"`
	PublicKey         ActorPublicKey    `json:"publicKey"`
	Endpoints         map[string]string `json:"endpoints,omitempty"`
	URL               string            `json:"url,omitempty"`
	OCINamespace      string            `json:"ociNamespace,omitempty"`
}

func FetchActor

func FetchActor(ctx context.Context, actorURL string) (*Actor, error)

FetchActor fetches and parses a remote actor profile, signing the GET request for compatibility with servers that require authenticated fetches (e.g. Mastodon secure mode).

func FetchActorSigned

func FetchActorSigned(ctx context.Context, actorURL string, identity *Identity) (*Actor, error)

FetchActorSigned fetches a remote actor, optionally signing the request.

func ParseActor

func ParseActor(data []byte) (*Actor, error)

type ActorCache

type ActorCache struct {
	// contains filtered or unexported fields
}

ActorCache provides a TTL-based cache for remote actor profiles.

func NewActorCache

func NewActorCache(identity *Identity) *ActorCache

func (*ActorCache) Get

func (c *ActorCache) Get(ctx context.Context, actorURL string) (*Actor, error)

Get returns a cached actor or fetches it (with a signed request) if missing/expired.

func (*ActorCache) Invalidate

func (c *ActorCache) Invalidate(actorURL string)

func (*ActorCache) Stop

func (c *ActorCache) Stop()

type ActorHandler

type ActorHandler struct {
	// contains filtered or unexported fields
}

func NewActorHandler

func NewActorHandler(identity *Identity, nodeName, endpoint string) *ActorHandler

func (*ActorHandler) ServeHTTP

func (h *ActorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ActorInvalidator

type ActorInvalidator interface {
	Invalidate(actorURL string)
}

type ActorPublicKey

type ActorPublicKey struct {
	ID           string `json:"id"`
	Owner        string `json:"owner"`
	PublicKeyPEM string `json:"publicKeyPem"`
}

type AdapterRegistry added in v0.0.27

type AdapterRegistry struct {
	// contains filtered or unexported fields
}

func NewAdapterRegistry added in v0.0.27

func NewAdapterRegistry() *AdapterRegistry

func (*AdapterRegistry) Lookup added in v0.0.27

func (r *AdapterRegistry) Lookup(apType string) FederationAdapter

func (*AdapterRegistry) Register added in v0.0.27

func (r *AdapterRegistry) Register(a FederationAdapter) error

type BlobReplicator

type BlobReplicator interface {
	ReplicateBlob(ctx context.Context, peerEndpoint, digest string, size int64)
}

type DeliveryQueue

type DeliveryQueue struct {
	// contains filtered or unexported fields
}

func NewDeliveryQueue

func NewDeliveryQueue(db DeliveryRepository, identity *Identity, logger *slog.Logger) *DeliveryQueue

func (*DeliveryQueue) Notify

func (q *DeliveryQueue) Notify()

func (*DeliveryQueue) PreWarmCircuit added in v0.0.9

func (q *DeliveryQueue) PreWarmCircuit(ctx context.Context)

PreWarmCircuit loads unhealthy peer domains from the DB and opens the circuit breaker for each one. Call this once before Start to ensure a restart during an outage doesn't immediately retry all dead peers.

func (*DeliveryQueue) Start

func (q *DeliveryQueue) Start(ctx context.Context)

func (*DeliveryQueue) Stop

func (q *DeliveryQueue) Stop()

Stop signals the worker to stop and waits for it to finish.

type DeliveryRepository added in v0.0.9

type DeliveryRepository interface {
	PendingDeliveries(ctx context.Context, limit int) ([]database.Delivery, error)
	MarkDeliveryFailed(ctx context.Context, id int64, attempts, maxAttempts int, lastError string) error
	MarkDelivered(ctx context.Context, id int64) error
	CleanupDeliveries(ctx context.Context, olderThan time.Duration) (int64, error)
	SetPeerHealthByDomain(ctx context.Context, domain string, healthy bool) error
	UnhealthyPeerDomains(ctx context.Context) ([]string, error)
}

type EnqueueFunc

type EnqueueFunc func(ctx context.Context, activityID, inboxURL string, activityJSON []byte) error

type FedError added in v0.0.9

type FedError struct {
	Kind    FedErrorKind
	Message string
	Err     error
}

FedError is a typed federation error that carries an HTTP status code and an appropriate log level. Inspired by GoToSocial's WithCode error.

func AsFedError added in v0.0.9

func AsFedError(err error) (*FedError, bool)

AsFedError extracts a *FedError from err if present.

func (*FedError) Error added in v0.0.9

func (e *FedError) Error() string

func (*FedError) HTTPCode added in v0.0.9

func (e *FedError) HTTPCode() int

func (*FedError) LogLevel added in v0.0.9

func (e *FedError) LogLevel() slog.Level

ErrNotRelevant is debug-only; all other kinds log at warn.

func (*FedError) Unwrap added in v0.0.9

func (e *FedError) Unwrap() error

type FedErrorKind added in v0.0.9

type FedErrorKind int

FedErrorKind classifies federation errors so callers can choose the right HTTP response code and log level without string-matching error messages.

const (
	ErrMalformed       FedErrorKind = iota // 400 — bad ActivityPub payload
	ErrUnauthorized                        // 401 — signature verification failed
	ErrForbidden                           // 403 — blocked actor or domain
	ErrNotRelevant                         // 200 — activity doesn't apply (log at debug)
	ErrPeerUnreachable                     // 502 — remote resource fetch failed
)

type FederationAdapter added in v0.0.27

type FederationAdapter interface {
	PackageType() string
	APTypes() []string
	Ingest(ctx context.Context, activityType, apType string, obj map[string]any, actorURL string) error
}

type FollowersHandler

type FollowersHandler struct {
	// contains filtered or unexported fields
}

func NewFollowersHandler

func NewFollowersHandler(identity *Identity, db FollowersRepository) *FollowersHandler

func (*FollowersHandler) ServeHTTP

func (h *FollowersHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FollowersRepository added in v0.0.9

type FollowersRepository interface {
	CountFollows(ctx context.Context) (int, error)
	ListFollowsBatch(ctx context.Context, afterID int64, limit int) ([]database.Actor, error)
}

type FollowingHandler

type FollowingHandler struct {
	// contains filtered or unexported fields
}

FollowingHandler returns who this instance is following (outgoing follows).

func NewFollowingHandler

func NewFollowingHandler(identity *Identity, db FollowingRepository) *FollowingHandler

func (*FollowingHandler) ServeHTTP

func (h *FollowingHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type FollowingRepository added in v0.0.9

type FollowingRepository interface {
	ListOutgoingFollows(ctx context.Context, status string) ([]database.Actor, error)
	CountOutgoingFollows(ctx context.Context, status string) (int, error)
	ListOutgoingFollowsBatch(ctx context.Context, status string, afterID int64, limit int) ([]database.Actor, error)
}

FollowingRepository is the persistence port for the following handler.

type Identity

type Identity struct {
	ActorURL      string
	Domain        string
	AccountDomain string
	PrivateKey    *ecdsa.PrivateKey
	Logger        *slog.Logger
}

func LoadOrCreateIdentity

func LoadOrCreateIdentity(endpoint, domain, accountDomain, keyPath string, logger *slog.Logger) (*Identity, error)

func (*Identity) KeyID

func (id *Identity) KeyID() string

func (*Identity) PublicKeyPEM

func (id *Identity) PublicKeyPEM() (string, error)

type InboxConfig

type InboxConfig struct {
	MaxManifestSize int64
	MaxBlobSize     int64
	AutoAccept      string
	AllowedDomains  []string
	BlockedDomains  []string
	BlockedActors   []string
}

type InboxDispatcher added in v0.0.9

type InboxDispatcher interface {
	// contains filtered or unexported methods
}

InboxDispatcher processes incoming ActivityPub tasks.

type InboxHandler

type InboxHandler struct {
	// contains filtered or unexported fields
}

func NewInboxHandler

func NewInboxHandler(identity *Identity, db InboxRepository, cfg InboxConfig, logger *slog.Logger) *InboxHandler

func (*InboxHandler) BlockedActors added in v0.0.40

func (h *InboxHandler) BlockedActors() []string

BlockedActors returns the currently blocked actor URLs, sorted.

func (*InboxHandler) BlockedDomains added in v0.0.40

func (h *InboxHandler) BlockedDomains() []string

BlockedDomains returns the currently blocked domains, sorted.

func (*InboxHandler) PauseActor added in v0.0.40

func (h *InboxHandler) PauseActor(actorURL string)

PauseActor blocks all inbound activities from a single actor URL.

func (*InboxHandler) PauseDomain added in v0.0.40

func (h *InboxHandler) PauseDomain(domain string)

PauseDomain blocks all inbound activities from domain and its subdomains without a restart. Resume with ResumeDomain.

func (*InboxHandler) ResumeActor added in v0.0.40

func (h *InboxHandler) ResumeActor(actorURL string)

ResumeActor lifts a PauseActor block.

func (*InboxHandler) ResumeDomain added in v0.0.40

func (h *InboxHandler) ResumeDomain(domain string)

ResumeDomain lifts a PauseDomain block. It has no effect on domains blocked via static config once that config is reloaded.

func (*InboxHandler) ServeHTTP

func (h *InboxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*InboxHandler) SetActorCache

func (h *InboxHandler) SetActorCache(c ActorInvalidator)

func (*InboxHandler) SetAdapters added in v0.0.27

func (h *InboxHandler) SetAdapters(r *AdapterRegistry)

func (*InboxHandler) SetBlobReplicator

func (h *InboxHandler) SetBlobReplicator(r BlobReplicator)

func (*InboxHandler) SetEnqueueFunc

func (h *InboxHandler) SetEnqueueFunc(fn EnqueueFunc)

func (*InboxHandler) SetNamespaceForActor added in v0.0.5

func (h *InboxHandler) SetNamespaceForActor(actorURL, namespace string)

SetNamespaceForActor pre-populates the namespace cache for a given actor, bypassing the actor fetch. Intended for testing.

func (*InboxHandler) SetNotifier added in v0.0.8

func (h *InboxHandler) SetNotifier(n Notifier)

func (*InboxHandler) SetWorker added in v0.0.5

func (h *InboxHandler) SetWorker(w ActivityEnqueuer)

func (*InboxHandler) Stop

func (h *InboxHandler) Stop()

type InboxRepository added in v0.0.9

type InboxRepository interface {
	InsertActivityIfNew(ctx context.Context, activityID, activityType, actorURL string, activityJSON []byte) (bool, error)
	AddFollowRequest(ctx context.Context, actorURL, publicKeyPEM, endpoint string, alias *string) error
	AcceptFollowRequest(ctx context.Context, actorURL string) error
	RejectFollowRequest(ctx context.Context, actorURL string) error
	GetFollowRequest(ctx context.Context, actorURL string) (*database.FollowRequest, error)
	GetFollow(ctx context.Context, actorURL string) (*database.Actor, error)
	RemoveFollow(ctx context.Context, actorURL string) error
	GetOutgoingFollow(ctx context.Context, actorURL string) (*database.Actor, error)
	AcceptOutgoingFollow(ctx context.Context, actorURL string) error
	RejectOutgoingFollow(ctx context.Context, actorURL string) error
	GetRepository(ctx context.Context, name string) (*database.Repository, error)
	GetOrCreateRepository(ctx context.Context, name, ownerDID string) (*database.Repository, error)
	IsRepositoryOwner(ctx context.Context, repoID int64, did string) (bool, error)
	PutManifest(ctx context.Context, m *database.Manifest) error
	GetManifestByDigest(ctx context.Context, repoID int64, digest string) (*database.Manifest, error)
	PutManifestLayers(ctx context.Context, manifestID int64, refs []database.BlobRef) error
	DeleteManifest(ctx context.Context, repoID int64, digest string) error
	RecordDeletedManifest(ctx context.Context, digest, repoName, sourceActor string) error
	PutTag(ctx context.Context, repoID int64, name, manifestDigest string) error
	DeleteTag(ctx context.Context, repoID int64, name string) error
	FindPeersWithBlob(ctx context.Context, digest string) ([]database.PeerBlob, error)
	GetBlob(ctx context.Context, digest string) (*database.Blob, error)
	PutBlob(ctx context.Context, digest string, sizeBytes int64, mediaType *string, storedLocally bool) error
	PutPeerBlob(ctx context.Context, peerActor, blobDigest, peerEndpoint string) error
}

type InboxTask added in v0.0.5

type InboxTask struct {
	Activity  RawActivity
	PubKeyPEM string
	RawBody   []byte
}

InboxTask is a validated activity ready for processing.

type InboxWorker added in v0.0.5

type InboxWorker struct {
	// contains filtered or unexported fields
}

InboxWorker processes validated ActivityPub activities asynchronously.

func NewInboxWorker added in v0.0.5

func NewInboxWorker(handler InboxDispatcher, logger *slog.Logger) *InboxWorker

func (*InboxWorker) Enqueue added in v0.0.5

func (w *InboxWorker) Enqueue(task InboxTask) bool

Enqueue pushes a task for async processing. Returns false if the queue is full.

func (*InboxWorker) Start added in v0.0.5

func (w *InboxWorker) Start(ctx context.Context)

func (*InboxWorker) Stop added in v0.0.5

func (w *InboxWorker) Stop()

type NodeInfo

type NodeInfo struct {
	Version           string           `json:"version"`
	Software          NodeInfoSoftware `json:"software"`
	Protocols         []string         `json:"protocols"`
	Usage             NodeInfoUsage    `json:"usage"`
	OpenRegistrations bool             `json:"openRegistrations"`
	Metadata          map[string]any   `json:"metadata"`
}

type NodeInfoHandler

type NodeInfoHandler struct {
	// contains filtered or unexported fields
}

func NewNodeInfoHandler

func NewNodeInfoHandler(domain, version string) *NodeInfoHandler

func (*NodeInfoHandler) ServeNodeInfo

func (h *NodeInfoHandler) ServeNodeInfo(w http.ResponseWriter, r *http.Request)

func (*NodeInfoHandler) ServeWellKnown

func (h *NodeInfoHandler) ServeWellKnown(w http.ResponseWriter, r *http.Request)

type NodeInfoSoftware

type NodeInfoSoftware struct {
	Name       string `json:"name"`
	Version    string `json:"version"`
	Repository string `json:"repository,omitempty"`
	Homepage   string `json:"homepage,omitempty"`
}

type NodeInfoUsage

type NodeInfoUsage struct {
	Users      NodeInfoUsers `json:"users"`
	LocalPosts int           `json:"localPosts"`
}

type NodeInfoUsers

type NodeInfoUsers struct {
	Total          int `json:"total"`
	ActiveMonth    int `json:"activeMonth"`
	ActiveHalfyear int `json:"activeHalfyear"`
}

type NodeInfoWellKnown

type NodeInfoWellKnown struct {
	Links []NodeInfoWellKnownLink `json:"links"`
}
type NodeInfoWellKnownLink struct {
	Rel  string `json:"rel"`
	Href string `json:"href"`
}

type Notifier added in v0.0.9

type Notifier interface {
	Send(event, message string)
}

type OCIBlob

type OCIBlob struct {
	Context      []string `json:"@context"`
	Type         string   `json:"type"`
	ID           string   `json:"id"`
	AttributedTo string   `json:"attributedTo"`
	Published    string   `json:"published"`
	Digest       string   `json:"ociDigest"`
	Size         int64    `json:"ociSize"`
	Endpoint     string   `json:"ociEndpoint"`
}

type OCIManifest

type OCIManifest struct {
	Context       []string `json:"@context"`
	Type          string   `json:"type"`
	ID            string   `json:"id"`
	AttributedTo  string   `json:"attributedTo"`
	Published     string   `json:"published"`
	Repository    string   `json:"ociRepository"`
	Digest        string   `json:"ociDigest"`
	MediaType     string   `json:"ociMediaType"`
	Size          int64    `json:"ociSize"`
	Content       string   `json:"ociContent,omitempty"`
	SubjectDigest string   `json:"ociSubjectDigest,omitempty"`
	Tag           string   `json:"ociTag,omitempty"`
}

type OCITag

type OCITag struct {
	Context      []string `json:"@context"`
	Type         string   `json:"type"`
	ID           string   `json:"id"`
	AttributedTo string   `json:"attributedTo"`
	Published    string   `json:"published"`
	Repository   string   `json:"ociRepository"`
	Tag          string   `json:"ociTag"`
	Digest       string   `json:"ociDigest"`
}

type OutboxHandler

type OutboxHandler struct {
	// contains filtered or unexported fields
}

func NewOutboxHandler

func NewOutboxHandler(identity *Identity, db OutboxRepository) *OutboxHandler

func (*OutboxHandler) ServeHTTP

func (h *OutboxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type OutboxRepository added in v0.0.9

type OutboxRepository interface {
	CountActivities(ctx context.Context, actorURL string) (int, error)
	ListActivitiesPage(ctx context.Context, actorURL string, beforeID int64, limit int) ([]database.Activity, error)
}

type PackagePublisher added in v0.0.27

type PackagePublisher interface {
	Publish(ctx context.Context, activityType string, object any) error
}

type PublisherRepository added in v0.0.9

type PublisherRepository interface {
	PutActivity(ctx context.Context, activityID, activityType, actorURL string, activityJSON []byte) error
	ListFollowsBatch(ctx context.Context, afterID int64, limit int) ([]database.Actor, error)
	EnqueueDeliveryInserted(ctx context.Context, activityID, inboxURL string, activityJSON []byte) (bool, error)
}

type RawActivity

type RawActivity struct {
	Context any    `json:"@context,omitempty"`
	ID      string `json:"id"`
	Type    string `json:"type"`
	Actor   string `json:"actor"`
	Object  any    `json:"object"`
}

type ResolverRepository added in v0.0.9

type ResolverRepository interface {
	FindPeersWithBlob(ctx context.Context, digest string) ([]database.PeerBlob, error)
}

type SignatureCache

type SignatureCache struct {
	// contains filtered or unexported fields
}

func NewSignatureCache

func NewSignatureCache() *SignatureCache

func (*SignatureCache) Stop

func (sc *SignatureCache) Stop()

type WebFingerClient added in v0.0.9

type WebFingerClient struct {
	// contains filtered or unexported fields
}

WebFingerClient handles WebFinger lookups with caching and deduplication. Call Stop() when done to release the background goroutine.

func NewWebFingerClient added in v0.0.9

func NewWebFingerClient() *WebFingerClient

func (*WebFingerClient) Lookup added in v0.0.9

func (c *WebFingerClient) Lookup(_ context.Context, domain, resource string) (string, error)

Lookup resolves a resource via WebFinger and returns the AP actor URL. Results are cached for webfingerCacheTTL to avoid repeated lookups.

func (*WebFingerClient) Stop added in v0.0.9

func (c *WebFingerClient) Stop()

type WebFingerHandler

type WebFingerHandler struct {
	// contains filtered or unexported fields
}

func NewWebFingerHandler

func NewWebFingerHandler(identity *Identity) *WebFingerHandler

func (*WebFingerHandler) ServeHTTP

func (h *WebFingerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WebFingerLink struct {
	Rel  string `json:"rel"`
	Type string `json:"type,omitempty"`
	Href string `json:"href,omitempty"`
}

type WebFingerResponse

type WebFingerResponse struct {
	Subject string          `json:"subject"`
	Aliases []string        `json:"aliases,omitempty"`
	Links   []WebFingerLink `json:"links"`
}

Jump to

Keyboard shortcuts

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