outbox

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

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 MakeUndo

func MakeUndo(actorID string, activity mapof.Any) mapof.Any

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 added in v0.9.1

func (actor *Actor) ActorID() string

func (*Actor) Send

func (actor *Actor) Send(message mapof.Any)

Send pushes a message onto the outbound queue. This currently uses the To and CC fields, but not BTo and BCC. 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) SendActivity

func (actor *Actor) SendActivity(activityType string, object streams.Document)

SendActivity wraps a document in a standard ActivityStream envelope and sends it to the target. actor: The Actor that is sending the request activityType: The type of activity to send (e.g. "Create", "Update", "Accept", etc) object: The object of the activity (e.g. the post that is being created, updated, etc) recipient: The ActivityStream profile of the message recipient

func (*Actor) SendAnnounce added in v0.10.0

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

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

func (*Actor) SendCreate

func (actor *Actor) SendCreate(activity mapof.Any)

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(activity 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) 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) 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(activity 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 <-chan string) ActorOption

func WithPublicKey

func WithPublicKey(publicKeyID string) ActorOption

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

func WithQueue

func WithQueue(queue queue.Queue) ActorOption

WithQueue is an ActorOption that sets the outbound Queue for an Actor

type SendTask

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

SendTask implements the queue.Task interface

func NewSendTask

func NewSendTask(actor Actor, message mapof.Any, recipient streams.Document) SendTask

NewSendTask returns a fully initialized SendTask object

func (SendTask) Run

func (task SendTask) Run() error

type Uniquer

type Uniquer[T comparable] struct {
	// contains filtered or unexported fields
}

Uniquer is a utility class that helps to identify unique values

func NewUniquer

func NewUniquer[T comparable]() *Uniquer[T]

NewUniquer returns a fully initialized Uniquer object

func (*Uniquer[T]) IsDuplicate

func (u *Uniquer[T]) IsDuplicate(id T) bool

IsDuplicate returns TRUE if the value has been seen before.

func (*Uniquer[T]) IsUnique

func (u *Uniquer[T]) IsUnique(id T) bool

IsUnique returns TRUE if the value has not been seen before. Subsequent calls to IsUnique() with the same value will return FALSE.

Jump to

Keyboard shortcuts

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