outbox

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 15 Imported by: 3

README

Hannibal / outbox

Outbox mimics an ActivityPub outbox. Passing a document to the outbox will use an outbound retry-queue to deliver it to all recipients in to, cc, and bto fields.


// Get an Actor's outbox
actor := outbox.New(myActor, outbox.WithClient(myClient), outbox.WithQueue(myQueue))

// The document is the ActivityPub document you're sending
document := map[string]any{
	"@context": vocab.ContextTypeDefault.
	"type": vocab.ActivityTypeCreate,
	"actor": actor.ActorID,
	"object": map[string]any{
		"type": "Note",
		"name": "A new note",	
	},
}

// Send a document via the Actor's outbox
if err := actor.Send(document); err != nil {
	derp.Report(err)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignRequest

func SignRequest(actor Actor) remote.Option

SignRequest is a middleware for the remote package that adds an HTTP Signature to a request.

Types

type Actor

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

Actor represents an ActivityPub actor that can send ActivityPub messages https://www.w3.org/TR/activitypub/#actors

func NewActor

func NewActor(actorID string, privateKey crypto.PrivateKey, options ...ActorOption) Actor

NewActor returns a fully initialized Actor object, and applies optional settings as provided

func (*Actor) ActorID

func (actor *Actor) ActorID() string

func (*Actor) Send

func (actor *Actor) Send(message mapof.Any, recipients ...iter.Seq[string])

Send pushes a message onto the outbound queue, sending it to all recipients in the iterator. https://www.w3.org/TR/activitypub/#delivery

func (*Actor) SendAccept

func (actor *Actor) SendAccept(acceptID string, activity streams.Document)

SendAccept sends an "Accept" message to the recipient actor: The Actor that is sending the request activity: The activity that has been accepted (likely a "Follow" request)

func (*Actor) SendAnnounce

func (actor *Actor) SendAnnounce(announceID string, object streams.Document)

SendAccept sends an "Announce" message to the recipient activity: The activity that is being announced

func (*Actor) SendCreate

func (actor *Actor) SendCreate(document streams.Document)

SendCreate sends an "Create" message to the recipient actor: The Actor that is sending the request activity: The activity that has been created (such as a "Note" or "Article") recipient: The profile of the message recipient

func (*Actor) SendDelete

func (actor *Actor) SendDelete(document streams.Document)

SendDelete sends an "Delete" message to the recipient actor: The Actor that is sending the request activity: The activity that has been deleted recipient: The ActivityStream profile of the message recipient

func (*Actor) SendDislike added in v0.13.0

func (actor *Actor) SendDislike(dislikeID string, object streams.Document)

SendDislike sends an "Dislike" message to the recipient activity: The activity that is being announced

func (*Actor) SendFollow

func (actor *Actor) SendFollow(followID string, remoteActorID string)

SendFollow sends a "Follow" request to the recipient actor: The Actor that is sending the request followID: The unique ID of this request recipient: The ActivityStream profile of the Actor that is being followed

func (*Actor) SendLike added in v0.13.0

func (actor *Actor) SendLike(likeID string, object streams.Document)

SendLike sends an "Like" message to the recipient activity: The activity that is being announced

func (*Actor) SendOne added in v0.11.23

func (actor *Actor) SendOne(recipientID string, message mapof.Any) error

SendOne sends a single message to a single recipient

func (*Actor) SendUndo

func (actor *Actor) SendUndo(activity streams.Document)

SendUndo sends an "Undo" message to the recipient actor: The Actor that is sending the request activity: The activity that has been undone recipient: The ActivityStream profile of the message recipient

func (*Actor) SendUpdate

func (actor *Actor) SendUpdate(document streams.Document)

SendUpdate sends an "Update" message to the recipient actor: The Actor that is sending the request activity: The activity that has been updated recipient: The ActivityStream profile of the message recipient

func (*Actor) With

func (actor *Actor) With(options ...ActorOption)

With applies one or more options to an Actor

type ActorOption

type ActorOption func(*Actor)

ActorOption is a function signature that modifies optional settings for an Actor

func WithClient

func WithClient(client streams.Client) ActorOption

WithCliient is an ActorOption that sets the hanibal Client for an Actor

func WithFollowers

func WithFollowers(followers iter.Seq[string]) ActorOption

func WithPublicKey

func WithPublicKey(publicKeyID string) ActorOption

WithPublicKey is an ActorOption that sets the public key for an Actor

Jump to

Keyboard shortcuts

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