client

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: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Store(string, []byte, time.Duration) error
	Load(string) ([]byte, error)
}

Cache defines an interface for caching and reading the received objects.

type Client

type Client struct {
	InstanceURL *url.URL
	Cache       Cache
	Client      *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(instance *url.URL, address string, password string, datastore Datastore) *Client

NewClient initializes a client to retrieve and cache ActivityPub objects.

func (*Client) Announce

func (c *Client) Announce(ctx context.Context, announce vocab.ActivityStreamsAnnounce, depth int, maxDepth int) error

Announce dereferences the actor and object fields of the activity.

func (*Client) Create

func (c *Client) Create(ctx context.Context, create vocab.ActivityStreamsCreate, depth int, maxDepth int) error

Create dereferences the actor and object fields of the activity.

func (*Client) DereferenceActor

func (c *Client) DereferenceActor(ctx context.Context, actor vocab.ActivityStreamsActorProperty, depth, maxDepth int) error

DereferenceActor dereferences the Actor property by fetching from an IRI.

func (*Client) DereferenceAttributedTo

func (c *Client) DereferenceAttributedTo(ctx context.Context, attributedTo vocab.ActivityStreamsAttributedToProperty, depth, maxDepth int) error

DereferenceAttributedTo fetches the actors or objects in attributedTo field.

func (*Client) DereferenceFollowers

func (c *Client) DereferenceFollowers(ctx context.Context, followers vocab.ActivityStreamsFollowersProperty, depth, maxDepth int) error

DereferenceFollowers fetches the collection and dereferences items.

func (*Client) DereferenceFollowing

func (c *Client) DereferenceFollowing(ctx context.Context, following vocab.ActivityStreamsFollowingProperty, depth, maxDepth int) error

DereferenceFollowing fetches the collection and dereferences items.

func (*Client) DereferenceInReplyTo

func (c *Client) DereferenceInReplyTo(ctx context.Context, inReplyTo vocab.ActivityStreamsInReplyToProperty, depth, maxDepth int) error

DereferenceInReplyTo fetches the actors or objects in inReplyTo field.

func (*Client) DereferenceItem

func (c *Client) DereferenceItem(ctx context.Context, item vocab.Type, depth int, maxDepth int) (vocab.Type, error)

DereferenceItem will dereference activities and objects received.

func (*Client) DereferenceItems

func (c *Client) DereferenceItems(ctx context.Context, items vocab.ActivityStreamsItemsProperty, depth int, maxDepth int) error

DereferenceItems fetches and dereferences objects in orderedItems. This is performed concurrently up to some limit.

func (*Client) DereferenceObjectsInCollection

func (c *Client) DereferenceObjectsInCollection(ctx context.Context, collection vocab.ActivityStreamsCollection, page, depth, maxDepth int) (vocab.ActivityStreamsCollectionPage, error)

DereferenceObjectsInCollection retrieves items on the page and returns. If page is 0 then only the first page is dereferences. If the page is greater than the number of pages then

func (*Client) DereferenceObjectsInOrderedCollection

func (c *Client) DereferenceObjectsInOrderedCollection(ctx context.Context, collection vocab.ActivityStreamsOrderedCollection, page, depth, maxDepth int) (vocab.ActivityStreamsOrderedCollectionPage, error)

DereferenceObjectsInOrderedCollection retrieves items on the specified page. If page is 0 then only the first page is dereferences. If the page is greater than the number of pages then

func (*Client) DereferenceOrderedItems

func (c *Client) DereferenceOrderedItems(ctx context.Context, items vocab.ActivityStreamsOrderedItemsProperty, depth int, maxDepth int) error

DereferenceOrderedItems fetches and dereferences objects in orderedItems. This is performed concurrently up to some limit.

func (*Client) DereferenceOutbox

func (c *Client) DereferenceOutbox(ctx context.Context, outbox vocab.ActivityStreamsOutboxProperty, depth, maxDepth int) error

DereferenceOutbox fetches the outbox at a given IRI and dereferences items.

func (*Client) DereferenceRecipientInboxes

func (c *Client) DereferenceRecipientInboxes(ctx context.Context, a activity.Activity) ([]*url.URL, error)

func (*Client) Event

func (c *Client) Event(ctx context.Context, event vocab.ActivityStreamsEvent, depth int, maxDepth int) error

Event dereferences the fields up to the specified maxDepth on an Event. Dereferences "attributedTo" actors and objects.

func (*Client) FetchFollowers

func (c *Client) FetchFollowers(ctx context.Context, identifier string) ([]vocab.Type, error)

FetchFollowers determines the actors that follow a given person.

func (*Client) FetchObject

func (c *Client) FetchObject(ctx context.Context, iri *url.URL, forceUpdate bool, depth int, maxDepth int) (vocab.Type, error)

FetchObject retrieves the resource located at the provided IRI. The client makes use of caching but this can be overridden.

func (*Client) FetchRecipients

func (c *Client) FetchRecipients(ctx context.Context, a activity.Activity) ([]*url.URL, error)

FetchRecipients returns a list of Actor IDs to deliver the activity to.

func (*Client) FetchRemoteActor

func (c *Client) FetchRemoteActor(ctx context.Context, identifier string) (actor.Actor, error)

FetchRemoteActor performs a Webfinger lookup and returns an Actor.

func (*Client) FetchRemotePerson

func (c *Client) FetchRemotePerson(ctx context.Context, identifier string) (vocab.ActivityStreamsPerson, error)

FetchRemotePerson performs a Webfinger lookup and returns a Person.

func (*Client) FetchRemotePersonWithID

func (c *Client) FetchRemotePersonWithID(ctx context.Context, personID *url.URL) (vocab.ActivityStreamsPerson, error)

FetchRemotePersonWithID uses the provided ID to retrieve a Person.

func (*Client) Invite

func (c *Client) Invite(ctx context.Context, invite vocab.ActivityStreamsInvite, depth int, maxDepth int) error

Invite dereferences the actor and object fields of the activity.

func (*Client) Like

func (c *Client) Like(ctx context.Context, like vocab.ActivityStreamsLike, depth int, maxDepth int) error

Like dereferences the actor fields of the activity.

func (*Client) LookupInstanceDetails

func (c *Client) LookupInstanceDetails(ctx context.Context, instanceURL *url.URL) (*InstanceDetails, error)

LookupInstanceDetails checks if the URL is a FediUni instance.

func (*Client) Note

func (c *Client) Note(ctx context.Context, note vocab.ActivityStreamsNote, depth int, maxDepth int) error

Note dereferences the fields up to the specified maxDepth on a Note. Dereferences "attributedTo" and "replies". The first and second page of the replies are dereferenced by default.

func (*Client) PostToInbox

func (c *Client) PostToInbox(ctx context.Context, inbox *url.URL, object vocab.Type, keyID string, privateKey *rsa.PrivateKey) error

PostToInbox converts any activity to JSON and delivers to the inbox. Handles HTTP signatures.

func (*Client) ResolveActorIdentifierToID

func (c *Client) ResolveActorIdentifierToID(ctx context.Context, identifier string) (*url.URL, error)

ResolveActorIdentifierToID converts an identifier to an ID using Webfinger.

func (*Client) WebfingerLookup

func (c *Client) WebfingerLookup(ctx context.Context, domain string, username string) (*WebfingerResponse, error)

WebfingerLookup determines if an actor exists on an instance.

type Datastore

type Datastore interface {
	GetActivityByActivityID(context.Context, string) (activity.Activity, error)
	GetActorByActorID(context.Context, string) (actor.Person, error)
}

type InstanceDetails

type InstanceDetails struct {
	// Name is the name of the current server, e.g Society or Club Name.
	Name string
	// Institute indicates the associated institute of the current society.
	Institute string
}

type RedisCache

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

RedisCache wraps a Redis Client to implement the Cache interface.

func (*RedisCache) Load

func (c *RedisCache) Load(key string) ([]byte, error)

Load reads the provided value using provided key from the Redis store.

func (*RedisCache) Store

func (c *RedisCache) Store(key string, value []byte, expiration time.Duration) error

Store adds the provided value using the provided key to the Redis store.

type WebfingerLink struct {
	Rel  string `json:"rel"`
	Type string `json:"type"`
	Href string `json:"href"`
}

type WebfingerResponse

type WebfingerResponse struct {
	Subject string          `json:"subject"`
	Links   []WebfingerLink `json:"links"`
}

Jump to

Keyboard shortcuts

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