activitypub

package
v0.0.0-...-7e4e87f Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionsShow

func CollectionsShow(env *Env, w http.ResponseWriter, r *http.Request) error

func Follow

func Follow(ctx context.Context, follower *models.Account, target *models.Actor) error

Follow sends a follow request from the Account to the Target Actor's inbox.

func Followers

func Followers(env *Env, w http.ResponseWriter, r *http.Request) error

func Following

func Following(env *Env, w http.ResponseWriter, r *http.Request) error

func Like

func Like(ctx context.Context, liker *models.Account, target *models.Status) error

Like sends a like request from the Account to the Statuses Actor's inbox.

func Outbox

func Outbox(env *Env, w http.ResponseWriter, r *http.Request) error

func Unfollow

func Unfollow(ctx context.Context, follower *models.Account, target *models.Actor) error

Unfollow sends an unfollow request from the Account to the Target Actor's inbox.

func Unlike

func Unlike(ctx context.Context, liker *models.Account, target *models.Status) error

Unlike sends an undo like request from the Account to the Statuses Actor's inbox.

func UsersShow

func UsersShow(env *Env, w http.ResponseWriter, r *http.Request) error

Types

type Activity

type Activity struct {
	// Type is the type of the Activity.
	Type string `json:"type"`
	// The Activity's unique global identifier.
	ID string `json:"id"`
	// Object is the Object that the Activity is acting upon.
	Object any `json:"object"`
	// Actor is the Actor that performed the Activity.
	Actor any `json:"actor"`
	// Target is the Object that the Activity is directed at.
	Target string `json:"target"`

	Published time.Time `json:"published"`
	Updated   time.Time `json:"updated"`
}

Activity is an ActivityStreams Activity. https://www.w3.org/TR/activitystreams-core/#activities

type Attachment

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

type Client

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

Client is an ActivityPub client which can be used to fetch remote ActivityPub resources.

func NewClient

func NewClient(signAs *models.Account) (*Client, error)

NewClient returns a new ActivityPub client.

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, uri string, obj interface{}) error

Fetch fetches the ActivityPub resource at the given URL and decodes it into the given object.

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, obj map[string]any) error

Post posts the given ActivityPub object to the given URL.

func (*Client) RoundTrip

func (c *Client) RoundTrip(req *http.Request) (*http.Response, error)

type Collection

type Collection struct {
	Type       string `json:"type"`
	TotalItems int    `json:"totalItems"`
}

type Env

type Env struct {
	*gorm.DB
	*streaming.Mux
	Logger *slog.Logger
}

func (*Env) Log

func (e *Env) Log() *slog.Logger

type HashTag

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

HashTag is an ActivityStreams Hashtag

type Image

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

Image is an ActivityStreams Image

type InboxController

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

func NewInbox

func NewInbox(db *gorm.DB) *InboxController

func (*InboxController) Create

func (i *InboxController) Create(env *Env, w http.ResponseWriter, r *http.Request) error

type Item

type Item struct {
	ID        string   `json:"id"`
	Type      string   `json:"type"`
	Actor     string   `json:"actor"`
	Published string   `json:"published"`
	To        []string `json:"to"`
	CC        []string `json:"cc"`
	Object    any      `json:"object"`
}

type Object

type Object struct {
	// Type is the type of the Object.
	Type string `json:"type"`
}

Object is an ActivityPub Object. https://www.w3.org/TR/activitystreams-vocabulary/#dfn-object

type Option

type Option struct {
	Type    string     `json:"type"`
	Name    string     `json:"name"`
	Replies Collection `json:"replies"`
}

type RemoteActorFetcher

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

func NewRemoteActorFetcher

func NewRemoteActorFetcher(signAs *models.Account) *RemoteActorFetcher

func (*RemoteActorFetcher) Fetch

func (f *RemoteActorFetcher) Fetch(ctx context.Context, uri string) (*models.Actor, error)

type RemoteStatusFetcher

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

func NewRemoteStatusFetcher

func NewRemoteStatusFetcher(signAs *models.Account, db *gorm.DB) *RemoteStatusFetcher

func (*RemoteStatusFetcher) Fetch

func (f *RemoteStatusFetcher) Fetch(uri string) (*models.Status, error)

type Status

type Status struct {
	// Type is the type of the Status.
	Type string `json:"type"`
	// The Status's unique global identifier.
	ID string `json:"id"`

	AttributedTo string    `json:"attributedTo"`
	InReplyTo    string    `json:"inReplyTo"`
	Published    time.Time `json:"published"`
	Updated      time.Time `json:"updated"`

	To StringOrArray `json:"to"`
	CC StringOrArray `json:"cc"`

	Sensitive   bool          `json:"sensitive"`
	Summary     string        `json:"summary"`
	Content     string        `json:"content"`
	Attachments []interface{} `json:"attachment"`
	Tags        []HashTag     `json:"tag"`

	StartTime time.Time `json:"startTime"`
	EndTime   time.Time `json:"endTime"`
	OneOf     []Option  `json:"oneOf"`
}

type StringOrArray

type StringOrArray []string

func (*StringOrArray) UnmarshalJSON

func (s *StringOrArray) UnmarshalJSON(b []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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