cmd

package
v0.0.0-...-232f911 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const AppName = "FedBOX"
View Source
const URISeparator = "\n"

Variables

Functions

func BootstrapStorage

func BootstrapStorage(conf config.Options, service vocab.Item, l lw.Logger) error

func ByName

func ByName(names ...string) url.Values

func ByType

func ByType(types ...vocab.ActivityVocabularyType) url.Values

func ByURL

func ByURL(urls ...vocab.IRI) url.Values

func CreateService

func CreateService(r s.FullStorage, self vocab.Item) (err error)

func Errf

func Errf(s string, par ...any)

func IRIWithFilters

func IRIWithFilters(iri vocab.IRI, searchParams ...url.Values) vocab.IRI

func ResetStorage

func ResetStorage(conf config.Options, l lw.Logger) error

func SearchActorsIRI

func SearchActorsIRI(baseIRI vocab.IRI, searchParams ...url.Values) vocab.IRI

Types

type Accounts

type Accounts struct {
	Export  Export         `cmd:"" help:"Exports accounts metadata."`
	Import  Import         `cmd:"" help:"Imports accounts metadata."`
	GenKeys GenKeys        `cmd:"" help:"Generate public/private key pairs for actors that are missing them."`
	Pass    ChangePassword `cmd:"" help:"Change password for an actor."`
}

type ActorsCmd

type ActorsCmd struct {
	Add AddActorCmd `cmd:"" help:"Adds an ActivityPub actor."`
}

type AddActorCmd

type AddActorCmd struct {
	Type         vocab.ActivityVocabularyType `help:"The type of the ActivityPub actor to add."`
	KeyType      string                       `help:"Type of keys to generate: ${keyTypes}" enum:"${keyTypes}" default:"${defaultKeyType}"`
	AttributedTo vocab.IRI                    `help:"The IRI of the Actor we should use as author."`
	Tags         []string                     `name:"tag" help:"The tag(s) to attach to the actor."`
	Names        []string                     `arg:"" name:"name" help:"The name(s) of the actor."`
}

func (AddActorCmd) Run

func (a AddActorCmd) Run(ctl *Control) error

type AddClient

type AddClient struct {
	RedirectURIs []string `name:"redirect-uri" help:"The redirect URIs for current application"`
}

func (AddClient) Run

func (a AddClient) Run(ctl *Control) error

type AddCmd

type AddCmd struct {
	Type         vocab.ActivityVocabularyType `help:"The type of ActivityPub object(s) to create." default:"${defaultObjectTypes}"`
	Name         string                       `help:"The name of the ActivityPub object(s) to create."`
	AttributedTo string                       `help:"The IRI of the Actor we should use as author"`
	Tag          []string                     `help:"The tag(s) to attach to the object."`
}

func (AddCmd) Run

func (a AddCmd) Run(ctl *Control) error

type AddToken

type AddToken struct {
	Client string `help:"The client to use for generating the token"`
	Actor  string `arg:"" help:"The actor identifier we want to generate the authorization for (ID)"`
}

func (AddToken) Run

func (a AddToken) Run(ctl *Control) error

type BootstrapCmd

type BootstrapCmd struct {
	KeyType string `help:"Type of keys to generate: ${keyTypes}" enum:"${keyTypes}" default:"${defaultKeyType}"`
}

func (BootstrapCmd) Run

func (b BootstrapCmd) Run(ctl *Control) error

type CTL

type CTL struct {
	Url     url.URL          `help:"The URL used by the application."`
	Env     env.Type         `enum:"${envTypes}" help:"The environment to use. Expected values: ${envTypes}" default:"${defaultEnv}"`
	Verbose int              `counter:"v" help:"Increase verbosity level from the default associated with the environment settings."`
	Path    string           `path:"" help:"The path for the storage folder or socket" default:"." env:"STORAGE_PATH"`
	Version kong.VersionFlag `short:"V"`

	// Commands
	Pub         Pub         `cmd:"" name:"pub" alt:"ap" help:"ActivityPub management helper"`
	OAuth       OAuth       `cmd:"" name:"oauth"`
	Storage     Storage     `cmd:""`
	Accounts    Accounts    `cmd:"" help:"Accounts helper."`
	Maintenance Maintenance `cmd:"" help:"Toggle maintenance mode for the main FedBOX server."`
	Reload      Reload      `cmd:"" help:"Reload the main FedBOX server configuration"`
	Stop        Stop        `cmd:"" help:"Stops the main FedBOX server configuration"`
	// contains filtered or unexported fields
}

type ChangePassword

type ChangePassword struct {
	IRI vocab.IRI `arg:"" optional:"" name:"iri" help:"The actor for which to change the password."`
}

func (ChangePassword) Run

func (c ChangePassword) Run(ctl *Control) error

type Client

type Client struct {
	Add  AddClient `cmd:"" help:"Adds an OAuth2 client."`
	Del  DelClient `cmd:"" help:"Removes an existing OAuth2 client."`
	List LsClient  `cmd:"" help:"Lists existing OAuth2 clients."`
}

type Control

type Control struct {
	Conf    config.Options
	Logger  lw.Logger
	Service vocab.Actor
	Storage st.FullStorage
}

func InitControl

func InitControl(c *CTL, version string) (*Control, error)

func New

func New(db st.FullStorage, conf config.Options, l lw.Logger) (*Control, error)

func (*Control) AddActor

func (c *Control) AddActor(p *vocab.Person, pw []byte, author vocab.Actor) (*vocab.Person, error)

func (*Control) AddClient

func (c *Control) AddClient(pw []byte, redirectUris []string, u any) (string, error)

func (*Control) AddObject

func (c *Control) AddObject(p *vocab.Object, author vocab.Actor) (*vocab.Object, error)

func (*Control) CopyObjects

func (c *Control) CopyObjects(to vocab.IRI, from ...vocab.IRI) error

func (*Control) DeleteClient

func (c *Control) DeleteClient(id string) error

func (*Control) DeleteObjects

func (c *Control) DeleteObjects(reason string, inReplyTo []string, ids ...vocab.IRI) error

func (*Control) GenAuthToken

func (c *Control) GenAuthToken(clientID, actorIdentifier string, _ any) (string, error)

func (*Control) List

func (*Control) ListClients

func (c *Control) ListClients() ([]osin.Client, error)

func (*Control) MoveObjects

func (c *Control) MoveObjects(to vocab.IRI, from ...vocab.IRI) error

func (*Control) SendSignal

func (c *Control) SendSignal(sig syscall.Signal) error

type CopyCmd

type CopyCmd struct {
	To   vocab.IRI   `help:"Collection to which to move the objects." required:""`
	IRIs []vocab.IRI `arg:"" name:"iris"`
}

func (CopyCmd) Run

func (c CopyCmd) Run(ctl *Control) error

type DelClient

type DelClient struct {
	Client []string `arg:"" help:"Removes an existing OAuth2 client"`
}

func (DelClient) Run

func (d DelClient) Run(ctl *Control) error

type DeleteCmd

type DeleteCmd struct {
	Reason    string      `help:"The reason why we want to delete the item"`
	InReplyTo []string    `help:"If deletion is a followup on moderation activities"`
	IRIs      []vocab.IRI `arg:"" name:"iris"`
}

func (DeleteCmd) Run

func (d DeleteCmd) Run(ctl *Control) error

type Export

type Export struct{}

func (Export) Run

func (e Export) Run(ctl *Control) error

type ExportCmd

type ExportCmd struct {
	File string `help:"The path where to output the items, if absent it will be printed to stdout."`
}

func (ExportCmd) Run

func (e ExportCmd) Run(ctl *Control) error

type FixCollections

type FixCollections struct{}

func (FixCollections) Run

func (f FixCollections) Run(ctl *Control) error

type GenKeys

type GenKeys struct {
	Type string      `help:"Type of keys to generate." name:"key-type" enum:"${keyTypes}" default:"${defaultKeyType}"`
	IRIs []vocab.IRI `arg:"" optional:"" name:"iri" help:"Actors for which to generate the keys. Defaults to all actors if missing."`
}

func (GenKeys) Run

func (g GenKeys) Run(ctl *Control) error

type Import

type Import struct {
	Files []*os.File `arg:""`
}

func (Import) Run

func (i Import) Run(ctl *Control) error

type ImportCmd

type ImportCmd struct {
	Base  vocab.IRI  `help:"The base IRI to replace"`
	Files []*os.File `arg:""`
}

func (ImportCmd) Run

func (i ImportCmd) Run(ctl *Control) error

type IndexCmd

type IndexCmd struct{}

func (IndexCmd) Run

func (i IndexCmd) Run(ctl *Control) error

type InfoCmd

type InfoCmd struct {
	IRIs   []vocab.IRI `arg:"" name:"iris"`
	Output string      `help:"The format in which to output the items." enum:"text,json" default:"text"`
}

func (InfoCmd) Run

func (l InfoCmd) Run(ctl *Control) error

type ListCmd

type ListCmd struct {
	Type   []vocab.ActivityVocabularyType `help:"The type of ActivityPub object to list" default:"${defaultObjectTypes}"`
	Output string                         `help:"The format in which to output the items." enum:"text,json" default:"text"`
	IRIs   []vocab.IRI                    `arg:"" name:"iris"`
}

func (ListCmd) Run

func (l ListCmd) Run(ctl *Control) error

type LsClient

type LsClient struct{}

func (LsClient) Run

func (l LsClient) Run(ctl *Control) error

type Maintenance

type Maintenance struct{}

func (Maintenance) Run

func (m Maintenance) Run(ctl *Control) error

type MoveCmd

type MoveCmd struct {
	To   vocab.IRI   `help:"Collection to which to move the objects." required:""`
	IRIs []vocab.IRI `arg:"" name:"iris"`
}

func (MoveCmd) Run

func (m MoveCmd) Run(ctl *Control) error

type OAuth

type OAuth struct {
	Client Client `cmd:"" help:"OAuth2 client application management."`
	Token  Token  `cmd:"" help:"OAuth2 authorization token management."`
}

type Pub

type Pub struct {
	Actors ActorsCmd `cmd:"" name:"actor" help:"Actor management helper."`
	Add    AddCmd    `cmd:"" name:"add" help:"Adds a new object."`
	List   ListCmd   `cmd:"" help:"Lists objects."`
	Info   InfoCmd   `cmd:"" help:"Show information about an object."`
	Delete DeleteCmd `cmd:"" help:"Deletes an ActivityPub object."`
	Move   MoveCmd   `cmd:"" help:"Move ActivityPub objects to a new collection."`
	Copy   CopyCmd   `cmd:"" help:"Copy ActivityPub objects."`
	Index  IndexCmd  `cmd:"" help:"Reindex current storage ActivityPub objects."`
	Export ExportCmd `cmd:"" help:"Exports ActivityPub objects."`
	Import ImportCmd `cmd:"" help:"Imports ActivityPub objects."`
}

type Reload

type Reload struct{}

func (Reload) Run

func (m Reload) Run(ctl *Control) error

type ResetCmd

type ResetCmd struct{}

func (ResetCmd) Run

func (b ResetCmd) Run(ctl *Control) error

type Run

type Run struct {
	Wait    time.Duration    `help:"The duration for which the server waits for existing connections to finish" default:"${defaultWaitDuration}"`
	Env     env.Type         `enum:"${envTypes}" help:"The environment to use. Expected values: ${envTypes}" default:"${defaultEnv}"`
	Path    string           `path:"" help:"The path for the storage folder." default:"." env:"STORAGE_PATH"`
	Profile bool             `hidden:""`
	Version kong.VersionFlag `short:"V"`
}

func (Run) Run

func (r Run) Run(version string) error

type Stop

type Stop struct{}

func (Stop) Run

func (m Stop) Run(ctl *Control) error

type Storage

type Storage struct {
	Type config.StorageType `help:"Type of the backend to use. Possible values: ${storageTypes}"`

	Bootstrap      BootstrapCmd   `cmd:""`
	Reset          ResetCmd       `cmd:"" help:"Reset an existing storage."`
	FixCollections FixCollections `cmd:"" help:"Fix storage collections."`
}

type Token

type Token struct {
	Add AddToken `cmd:"" help:"Adds an OAuth2 token"`
}

Jump to

Keyboard shortcuts

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