actor

package
v0.0.0-...-19a598b Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsIdentifier

func IsIdentifier(identifier string) (bool, error)

IsIdentifier is of the form @username@domain then this function returns true.

func ParsePerson

func ParsePerson(ctx context.Context, actor vocab.Type) (vocab.ActivityStreamsPerson, error)

Types

type Actor

type Actor interface {
	vocab.Type
	GetActivityStreamsFollowers() vocab.ActivityStreamsFollowersProperty
	GetActivityStreamsFollowing() vocab.ActivityStreamsFollowingProperty
	GetActivityStreamsInbox() vocab.ActivityStreamsInboxProperty
	GetActivityStreamsOutbox() vocab.ActivityStreamsOutboxProperty
}

func ParseActor

func ParseActor(ctx context.Context, rawActor vocab.Type) (Actor, error)

ParseActor parses an Actor from the ActivityPub Object provided. Returns an Actor if it is a Person, Service, Group, Organization or Application.

type Datastore

type Datastore interface {
	GetActorByUsername(context.Context, string) (vocab.ActivityStreamsPerson, error)
	GetFollowersByUsername(context.Context, string) (vocab.ActivityStreamsOrderedCollection, error)
	GetFollowingByUsername(context.Context, string) (vocab.ActivityStreamsOrderedCollection, error)
	GetActorInbox(context.Context, string, string, string, bool) (vocab.ActivityStreamsOrderedCollectionPage, error)
	GetActorInboxAsOrderedCollection(context.Context, string, bool) (vocab.ActivityStreamsOrderedCollection, error)
	GetPublicInbox(context.Context, string, string, bool, bool) (vocab.ActivityStreamsOrderedCollectionPage, error)
	GetPublicInboxAsOrderedCollection(context.Context, bool, bool) (vocab.ActivityStreamsOrderedCollection, error)
	GetActorOutbox(context.Context, string, string, string) (vocab.ActivityStreamsOrderedCollectionPage, error)
	GetActorOutboxAsOrderedCollection(context.Context, string) (vocab.ActivityStreamsOrderedCollection, error)
	GetNotificationsInbox(ctx context.Context, username, minID, maxID string) (vocab.ActivityStreamsOrderedCollectionPage, error)
	GetNotificationsInboxAsOrderedCollection(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)
	GetEventInboxAsOrderedCollection(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)
	GetEventInbox(ctx context.Context, username, minID, maxID string) (vocab.ActivityStreamsOrderedCollectionPage, error)
	GetLikedAsOrderedCollection(context.Context, string) (vocab.ActivityStreamsOrderedCollection, error)
	GetLikeStatus(context.Context, *url.URL, *url.URL) (bool, error)
	UpdateActor(context.Context, string, string, string, vocab.ActivityStreamsImage) error
}

type KeyGenerator

type KeyGenerator interface {
	GenerateKeyPair() (string, string, error)
	WritePrivateKey(string) error
	GetPrivateKeyPEM() ([]byte, error)
}

type Person

Person is a type of Actor from https://www.w3.org/TR/activitypub/#actors.

type PersonGenerator

type PersonGenerator struct {
	InstanceURL  *url.URL
	KeyGenerator KeyGenerator
}

func NewPersonGenerator

func NewPersonGenerator(url *url.URL, keyGenerator KeyGenerator) *PersonGenerator

func (*PersonGenerator) GeneratePublicKey

func (p *PersonGenerator) GeneratePublicKey(username string) (vocab.W3IDSecurityV1PublicKey, error)

func (*PersonGenerator) NewPerson

func (p *PersonGenerator) NewPerson(ctx context.Context, username, displayName string) (Person, error)

type RSAKeyGenerator

type RSAKeyGenerator struct {
	PrivateKey *bytes.Buffer
	PublicKey  *bytes.Buffer
}

func NewRSAKeyGenerator

func NewRSAKeyGenerator() *RSAKeyGenerator

func (*RSAKeyGenerator) GenerateKeyPair

func (g *RSAKeyGenerator) GenerateKeyPair() (string, string, error)

func (*RSAKeyGenerator) GetPrivateKeyPEM

func (g *RSAKeyGenerator) GetPrivateKeyPEM() ([]byte, error)

func (*RSAKeyGenerator) WritePrivateKey

func (g *RSAKeyGenerator) WritePrivateKey(privateKeyPath string) error

type Server

type Server struct {
	URL         *url.URL
	Client      Client
	Datastore   Datastore
	FileHandler *file.Handler
}

func NewServer

func NewServer(url *url.URL, datastore Datastore, client Client, fileHandler *file.Handler) *Server

NewServer initializes a Server with methods for fetching actors and details.

func (*Server) GetAny

func (s *Server) GetAny(ctx context.Context, identifier string, statistics bool) (Actor, error)

GetAny returns any ActivityPub actor based on the provided identifier. Uses Webfinger to determine the actor ID based on the identifier provided. If the statistics parameter is true then the number of Followers, Actors Followed, and the amount of Activities in the Outbox is returned.

func (*Server) GetAnyOutbox

func (s *Server) GetAnyOutbox(ctx context.Context, identifier string, page int) (vocab.ActivityStreamsOrderedCollectionPage, error)

GetAnyOutbox fetches and dereferences any local or remote actor's outbox. The dereference page in the OrderedCollection is returned.

func (*Server) GetEventInboxAsOrderedCollection

func (s *Server) GetEventInboxAsOrderedCollection(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

func (*Server) GetEventInboxPage

func (s *Server) GetEventInboxPage(ctx context.Context, username, minID, maxID string) (vocab.ActivityStreamsOrderedCollectionPage, error)

func (*Server) GetFollowers

func (s *Server) GetFollowers(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

GetFollowers returns an OrderedCollection where items are Actor IRIs.

func (*Server) GetFollowing

func (s *Server) GetFollowing(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

GetFollowing returns an OrderedCollection where items are Actor IRIs.

func (*Server) GetInboxAsOrderedCollection

func (s *Server) GetInboxAsOrderedCollection(ctx context.Context, username string, local bool) (vocab.ActivityStreamsOrderedCollection, error)

GetInboxAsOrderedCollection returns an OrderedCollection with page IRIs.

func (*Server) GetInboxPage

func (s *Server) GetInboxPage(ctx context.Context, username, minID, maxID string, local bool) (vocab.ActivityStreamsOrderedCollectionPage, error)

GetInboxPage returns an OrderedCollectionPage with dereferenced objects.

func (*Server) GetLikeStatus

func (s *Server) GetLikeStatus(ctx context.Context, actorID *url.URL, objectID *url.URL) (bool, error)

GetLikeStatus returns true if the Actor liked the Object ID.

func (*Server) GetLikedAsOrderedCollection

func (s *Server) GetLikedAsOrderedCollection(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

GetLikedAsOrderedCollection returns an OrderedCollection of Like IRIs.

func (*Server) GetLocalPerson

func (s *Server) GetLocalPerson(ctx context.Context, username string, statistics bool) (vocab.Type, error)

GetLocalPerson returns the ActivityPub actor with the corresponding username. If the statistics parameter is true then the number of Followers, Actors Followed, and the amount of Activities in the Outbox is returned.

func (*Server) GetNotificationsInboxAsOrderedCollection

func (s *Server) GetNotificationsInboxAsOrderedCollection(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

func (*Server) GetNotificationsInboxPage

func (s *Server) GetNotificationsInboxPage(ctx context.Context, username, minID, maxID string) (vocab.ActivityStreamsOrderedCollectionPage, error)

func (*Server) GetOutbox

func (s *Server) GetOutbox(ctx context.Context, username string) (vocab.ActivityStreamsOrderedCollection, error)

GetOutbox returns an OrderedCollection with IRIs.

func (*Server) GetOutboxPage

func (s *Server) GetOutboxPage(ctx context.Context, username, minID, maxID string) (vocab.ActivityStreamsOrderedCollectionPage, error)

GetOutboxPage returns an OrderedCollectionPage with objects.

func (*Server) GetPublicInboxAsOrderedCollection

func (s *Server) GetPublicInboxAsOrderedCollection(ctx context.Context, local, institute bool) (vocab.ActivityStreamsOrderedCollection, error)

GetPublicInboxAsOrderedCollection returns an OrderedCollection with IRIs.

func (*Server) GetPublicInboxPage

func (s *Server) GetPublicInboxPage(ctx context.Context, minID, maxID string, local, institute bool) (vocab.ActivityStreamsOrderedCollectionPage, error)

GetPublicInboxPage returns an OrderedCollectionPage with objects.

func (*Server) UpdateLocal

func (s *Server) UpdateLocal(ctx context.Context, username, displayName, summary string, file multipart.File, header *multipart.FileHeader) error

UpdateLocal updates the internal representation of the actor. The mutable properties are the "name", "summary", and "icon". Handles directory creation and file naming.

Jump to

Keyboard shortcuts

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