ap

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ACCEPT_ACTIVITY string = "Accept"
View Source
const ACTIVITYSTREAMS_ACCEPT_HEADER string = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`

Deprecated, please use ACTIVITYSTREAMS_ACCEPT_HEADER

View Source
const ACTIVITYSTREAMS_CONTEXT string = "https://www.w3.org/ns/activitystreams"
View Source
const ACTIVITY_CONTENT_TYPE string = "application/activity+json"
View Source
const ACTIVITY_LD_CONTENT_TYPE string = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
View Source
const CREATE_ACTIVITY string = "Create"
View Source
const FOLLOW_ACTIVITY string = "Follow"

Variables

This section is empty.

Functions

func NewId

func NewId(uris_table *uris.URIs) string

NewId return a new identifier in the form of a unique URI.

Types

type Activity

type Activity struct {
	// Context needs to be a "whatever" (interface{}) because ActivityPub (JSON-LD)
	// mixes and matches string URIs, arbritrary data structures and arrays of string
	// URIs and arbritrary data structures in @context...
	Context interface{} `json:"@context,omitempty"`
	// Id is the unique identifier for the activity.
	Id string `json:"id"`
	// Type is the name of the activity being performed.
	Type string `json:"type"`
	// Actor is the URI of the person (actor) performing the activity.
	Actor string `json:"actor"`
	// To is the list of URIs the activity should be delivered to.
	To []string `json:"to,omitempty"`
	// CC is the list of URIs the activity should be copied to.
	Cc []string `json:"cc,omitempty"`
	// Object is body of the activity itself.
	Object    interface{} `json:"object,omitempty"`
	Published string      `json:"published,omitempty"`
}

Activity is a struct encapsulating an ActivityPub activity.

func NewAcceptActivity

func NewAcceptActivity(ctx context.Context, uris_table *uris.URIs, from string, object interface{}) (*Activity, error)

NewAcceptActvity returns a new `Activity` instance of type "Accept". The Accept activity "indicates that the actor accepts the object. The target property can be used in certain circumstances to indicate the context into which the object has been accepted."

func NewAnnounceActivity

func NewAnnounceActivity(ctx context.Context, uris_table *uris.URIs, from string, author_uri string, object interface{}) (*Activity, error)

NewAnnounceActivity will return an ActivityPub "Announce" activity from 'from' about 'object' (created by 'author_uri').

func NewBoostActivity

func NewBoostActivity(ctx context.Context, uris_table *uris.URIs, from string, author_uri string, object interface{}) (*Activity, error)

NewBoostActivity will return an ActivityPub "Announce" activity from 'from' about 'object' (created by 'author_uri').

func NewCreateActivity

func NewCreateActivity(ctx context.Context, uris_table *uris.URIs, from string, to []string, object interface{}) (*Activity, error)

NewCreateActivity returns a new `Activity` instance of type "Create".

func NewFollowActivity

func NewFollowActivity(ctx context.Context, uris_table *uris.URIs, from string, to string) (*Activity, error)

NewCreateActivity returns a new `Activity` instance of type "Follow".

func NewUndoFollowActivity

func NewUndoFollowActivity(ctx context.Context, uris_table *uris.URIs, from string, to string) (*Activity, error)

type Actor

type Actor struct {
	// It has to be an interface because JSON-LD... thanks, JSON-LD...
	Context           []interface{} `json:"@context"`
	Id                string        `json:"id"`
	Type              string        `json:"type"`
	PreferredUsername string        `json:"preferredUsername"`
	Inbox             string        `json:"inbox"`
	Outbox            string        `json:"outbox"`
	PublicKey         PublicKey     `json:"publicKey"`

	Following string `json:"following,omitempty"`
	Followers string `json:"followers,omitempty"`
	Name      string `json:"name,omitempty"`
	Summary   string `json:"summary,omitempty"`
	URL       string `json:"url,omitempty"`
	// Don't omitempty because if you do then false values are omitted
	// ManuallyApprovesFollowers bool   `json:"manuallyApprovesFollowers"`
	Discoverable bool          `json:"discoverable,omitempty"`
	Published    string        `json:"published,omitempty"`
	Icon         Icon          `json:"icon,omitempty"`
	Attachments  []*Attachment `json:"attachment,omitempty"` // Is this just a Mastodon-ism?
}

func (*Actor) PublicKeyRSA

func (a *Actor) PublicKeyRSA(ctx context.Context) (*rsa.PublicKey, error)

Returns the `rsa.PublicKey` instance for 'a'.

type Attachment

type Attachment struct {
	Type  string `json:"type"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Followers

type Followers struct {
	Context    string `json:"@context"`
	Id         string `json:"id"`
	Type       string `json:"type"`
	TotalItems uint32 `json:"totalItems"`
	First      string `json:"first"`
}

type Following

type Following struct {
	Context    string `json:"@context"`
	Id         string `json:"id"`
	Type       string `json:"type"`
	TotalItems uint32 `json:"totalItems"`
	First      string `json:"first"`
}

type Icon

type Icon struct {
	Type      string `json:"type"`
	MediaType string `json:"mediaType"`
	URL       string `json:"url"`
}

type Note

type Note struct {
	Type         string   `json:"type"`
	Id           string   `json:"id"`
	AttributedTo string   `json:"attributedTo"`
	InReplyTo    string   `json:"inReplyTo,omitempty"`
	Tags         []*Tag   `json:"tag,omitempty"`
	To           []string `json:"to"`
	Cc           []string `json:"cc"`
	Content      string   `json:"content"`
	URL          string   `json:"url"`
	Published    string   `json:"published"`
}

type OrderedCollection

type OrderedCollection struct {
	// It has to be an interface because JSON-LD... thanks, JSON-LD...
	Context     []interface{}  `json:"@context"`
	Id          string         `json:"id"`
	Summary     string         `json:"summary,omitempty"`
	Type        string         `json:"type"`
	TotalItems  int            `json:"totalItems"`
	OrderedItem []*interface{} `json:"orderedItems,omitempty"`
}

type PublicKey

type PublicKey struct {
	Id    string `json:"id"`
	Owner string `json:"owner"`
	PEM   string `json:"publicKeyPem"`
}

type Tag

type Tag struct {
	Href string `json:"href"`
	Name string `json:"name"`
	Type string `json:"type"`
}

Tag is a struct encapsulating details about a tag.

Jump to

Keyboard shortcuts

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