box

package module
v0.0.0-...-b5548bb Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 36 Imported by: 1

README

GoActivityPub helper tool for posting and fetching

This CLI tool is used to post to ONI and FedBOX services.

Documentation

Index

Constants

View Source
const (
	ByID                = index.ByID
	ByType              = index.ByType
	ByName              = index.ByName
	ByPreferredUsername = index.ByPreferredUsername
	BySummary           = index.BySummary
	ByContent           = index.ByContent
	ByActor             = index.ByActor
	ByObject            = index.ByObject
	ByRecipients        = index.ByRecipients
	ByAttributedTo      = index.ByAttributedTo
	ByInReplyTo         = index.ByInReplyTo
	ByPublished         = index.ByPublished
	ByUpdated           = index.ByUpdated
	ByCollection        = iota
)

Variables

View Source
var (
	AppName    = "box"
	AppVersion = "HEAD"
	AppWebsite = "git.sr.ht/~mariusor/box"
)
View Source
var Split = []byte{'\n', '\n', '\n'}

Functions

func Announce

func Announce(ap *client.C, actor vocab.Actor, l lw.Logger, iris ...string) error

func Appreciation

func Appreciation(ap *client.C, actor vocab.Actor, l lw.Logger, typ vocab.ActivityVocabularyType, iris ...string) error

func Author

func Author(b *Client, cred c2s) *vocab.Actor

func Collection

func Collection(b *Client, cred c2s, whichCollection vocab.CollectionPath, ff ...filters.Check) (vocab.Item, error)

func CollectionBitmap

func CollectionBitmap() index.Indexable

CollectionBitmap uses a slightly different logic than a regular index. For collections, instead of storing the item's extracted tokens to the reference of the object's IRI we use the collection IRI as a token, and we store the references to the collection's items in the bitmap.

func Delete

func Delete(ap *client.C, actor vocab.Actor, l lw.Logger, iris ...vocab.IRI) error

func ExtractCollectionItems

func ExtractCollectionItems(li vocab.LinkOrIRI) []uint64

ExtractCollectionItems returns the vocab.IRI tokens corresponding to the items in the collection of the received vocab.Item

func Follow

func Follow(ap *client.C, actor vocab.Actor, l lw.Logger, iri string, reason string) error

func FollowResponse

func FollowResponse(ap *client.C, actor vocab.Actor, l lw.Logger, typ vocab.ActivityVocabularyType, respondToFollows ...vocab.Item) error

func Follows

func Follows(b *Client, cred c2s) (vocab.ItemCollection, error)

func Instance

func Instance(b *Client, cred c2s) (*vocab.Actor, error)

func LoadCredentials

func LoadCredentials(b *Client, iri string) (*credentials.C2S, error)

func LoadIRI

func LoadIRI(b *Client, cred c2s, iri vocab.IRI) (vocab.Item, error)

func LoadItems

func LoadItems(b *Client, cred c2s, iris ...vocab.IRI) (vocab.ItemCollection, error)

func Logger

func Logger(b *Client) lw.Logger

func Moderate

func Moderate(ap *client.C, actor vocab.Actor, l lw.Logger, m Moderation) error

func OpenEditor

func OpenEditor(editor, file, content string) ([]byte, error)

func PostNote

func PostNote(ap *client.C, actor vocab.Actor, l lw.Logger, ob Object) error

func Print

func Print(item vocab.Item) error

func PrintActivityFn

func PrintActivityFn(s *strings.Builder, fn SearchFn) func(activity *vocab.Activity) error

func PrintActorFn

func PrintActorFn(s *strings.Builder, fn SearchFn) func(*vocab.Actor) error

func PrintActorIdentifier

func PrintActorIdentifier(s *strings.Builder, act *vocab.Actor) error

func PrintIntransitiveActivityFn

func PrintIntransitiveActivityFn(s *strings.Builder, fn SearchFn) func(activity *vocab.IntransitiveActivity) error

func PrintItem

func PrintItem(s *strings.Builder, fn SearchFn, it vocab.Item) error

func PrintItemIdentifier

func PrintItemIdentifier(s *strings.Builder, li vocab.LinkOrIRI) error

func PrintItemIdentifiers

func PrintItemIdentifiers(s *strings.Builder, auth vocab.ItemCollection) error

func PrintListItem

func PrintListItem(s *strings.Builder, fn SearchFn, i int, li vocab.LinkOrIRI) error

func PrintNaturalLanguage

func PrintNaturalLanguage(s *strings.Builder, nl vocab.NaturalLanguageValues) error

func PrintObjectFn

func PrintObjectFn(s *strings.Builder, fn SearchFn) func(*vocab.Object) error

func PrintObjectIdentifier

func PrintObjectIdentifier(s *strings.Builder, ob *vocab.Object) error

func RemoveFromRecipients

func RemoveFromRecipients(it vocab.Item, recipients ...vocab.Item) vocab.Item

func Save

func Save(ap *client.C, l lw.Logger, activities ...vocab.Item) error

func SaveCredentials

func SaveCredentials(b *Client, cl credentials.C2S) error

func URLPath

func URLPath(uu string) string

func Undo

func Undo(ap *client.C, actor vocab.Actor, l lw.Logger, iris ...string) error

func Upload

func Upload(ap *client.C, actor vocab.Actor, l lw.Logger, ats ...Attachment) error

func UseBasePath

func UseBasePath(path string) func(*Client) error

func UseLogger

func UseLogger(l lw.Logger) func(b *Client) error

func UseXDGPaths

func UseXDGPaths(app string) func(*Client) error

func ValidCredentials

func ValidCredentials(cl credentials.C2S) bool

func WithUserAgent

func WithUserAgent(ua string) func(*Client) error

func WrapFlattenedObjectInActivityOfType

func WrapFlattenedObjectInActivityOfType(actor vocab.Actor, typ vocab.ActivityVocabularyType, ob vocab.Item) vocab.Activity

func WrapObjectInActivityOfType

func WrapObjectInActivityOfType(actor vocab.Actor, typ vocab.ActivityVocabularyType, ob vocab.Item) vocab.Activity

func WrapObjectInAnnounce

func WrapObjectInAnnounce(actor vocab.Actor, ob vocab.Item) vocab.Activity

func WrapObjectInCreate

func WrapObjectInCreate(actor vocab.Actor, ob vocab.Item) vocab.Activity

func WrapObjectInDelete

func WrapObjectInDelete(actor vocab.Actor, ob vocab.Item) vocab.Activity

func WrapObjectInUndo

func WrapObjectInUndo(actor vocab.Actor, ob vocab.Item) vocab.Activity

func WrapObjectInUpdate

func WrapObjectInUpdate(actor vocab.Actor, ob vocab.Item) vocab.Activity

func WriteDataURLFromFile

func WriteDataURLFromFile(file *os.File, content io.Writer) error

Types

type Attachment

type Attachment struct {
	Content
	Exists     bool
	ID         vocab.IRI
	Type       string
	Recipients vocab.IRIs
	InReplyTo  vocab.IRIs

	File  map[string]*os.File
	Sizes map[string]image.Point
	// contains filtered or unexported fields
}

func LoadMediaObject

func LoadMediaObject(b *Client, cred c2s, iris ...vocab.IRI) ([]Attachment, error)

func (Attachment) Original

func (a Attachment) Original() *os.File

type Client

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

func New

func New(initFns ...fn) (*Client, error)

func (*Client) BuildCollectionFetches

func (b *Client) BuildCollectionFetches(ctx context.Context) []Fetch

func (*Client) CachePath

func (b *Client) CachePath() string

func (*Client) Client

func (b *Client) Client(ctx context.Context, cred c2s) *client.C

func (*Client) Close

func (b *Client) Close() error

func (*Client) DataPath

func (b *Client) DataPath() string

func (*Client) Follow

func (b *Client) Follow(ctx context.Context, fetches ...Fetch) error

func (*Client) Open

func (b *Client) Open() error

func (*Client) Save

func (b *Client) Save(items ...vocab.Item) error

func (*Client) Search

func (b *Client) Search(checks ...filters.Check) (vocab.ItemCollection, error)

func (*Client) SearchInCollection

func (b *Client) SearchInCollection(col vocab.IRI, checks ...filters.Check) (vocab.ItemCollection, error)

type Content

type Content struct {
	Name    vocab.NaturalLanguageValues
	Summary vocab.NaturalLanguageValues
	Content vocab.NaturalLanguageValues
}

func FromTemplate

func FromTemplate(data []byte) Content

type Fetch

type Fetch struct {
	C           *client.C
	Collections []vocab.IRI
	// contains filtered or unexported fields
}

type Moderation

type Moderation struct {
	Type    vocab.ActivityVocabularyType
	Reason  vocab.NaturalLanguageValues
	Targets vocab.IRIs
}

type Object

type Object struct {
	Content
	ID         vocab.IRI
	Exists     bool
	Type       string
	Recipients vocab.IRIs
	InReplyTo  vocab.IRIs

	Attachments []string
	// contains filtered or unexported fields
}

func LoadTextObject

func LoadTextObject(b *Client, cred c2s, iris ...vocab.IRI) ([]Object, error)

type SearchFn

type SearchFn func(...filters.Check) (vocab.ItemCollection, error)

type Storage

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

func NewStorage

func NewStorage(path string) (*Storage, error)

func (*Storage) AddIndex

func (st *Storage) AddIndex(it vocab.LinkOrIRI) error

func (*Storage) Close

func (st *Storage) Close() error

func (*Storage) Load

func (st *Storage) Load(iri vocab.IRI) (vocab.LinkOrIRI, error)

func (*Storage) Open

func (st *Storage) Open() error

func (*Storage) Save

func (st *Storage) Save(it vocab.LinkOrIRI) error

func (*Storage) Search

func (st *Storage) Search(checks ...filters.Check) (vocab.ItemCollection, error)

func (*Storage) SearchInCollection

func (st *Storage) SearchInCollection(col vocab.IRI, checks ...filters.Check) (vocab.ItemCollection, error)

Directories

Path Synopsis
cmd
box command
internal
tui

Jump to

Keyboard shortcuts

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