admin

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actions added in v0.12.0

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

func (*Actions) GetRunning added in v0.12.0

func (a *Actions) GetRunning() []*gtsmodel.AdminAction

GetRunning sounds like a threat, but it actually just returns all of the currently running actions held by the Actions struct, ordered by ID descending.

func (*Actions) Run added in v0.12.0

Run runs the given admin action by executing the supplied function.

Run handles locking, action insertion and updating, so you don't have to!

If an action is already running which overlaps/conflicts with the given action, an ErrorWithCode 409 will be returned.

If execution of the provided function returns errors, the errors will be updated on the provided admin action in the database.

func (*Actions) TotalRunning added in v0.12.0

func (a *Actions) TotalRunning() int

TotalRunning is a sequel to the classic 1972 environmental-themed science fiction film Silent Running, starring Bruce Dern.

type Processor

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

func New

func New(
	state *state.State,
	cleaner *cleaner.Cleaner,
	converter *typeutils.Converter,
	mediaManager *media.Manager,
	transportController transport.Controller,
	emailSender email.Sender,
) Processor

New returns a new admin processor.

func (*Processor) AccountAction added in v0.2.2

func (p *Processor) AccountAction(
	ctx context.Context,
	adminAcct *gtsmodel.Account,
	request *apimodel.AdminActionRequest,
) (string, gtserror.WithCode)

func (*Processor) Actions added in v0.12.0

func (p *Processor) Actions() *Actions

func (*Processor) CreateAllowHeaderFilter added in v0.14.0

func (p *Processor) CreateAllowHeaderFilter(ctx context.Context, admin *gtsmodel.Account, request *apimodel.HeaderFilterRequest) (*apimodel.HeaderFilter, gtserror.WithCode)

CreateAllowHeaderFilter inserts the incoming allow HTTP header filter into the database, marking as authored by provided admin account.

func (*Processor) CreateBlockHeaderFilter added in v0.14.0

func (p *Processor) CreateBlockHeaderFilter(ctx context.Context, admin *gtsmodel.Account, request *apimodel.HeaderFilterRequest) (*apimodel.HeaderFilter, gtserror.WithCode)

CreateBlockHeaderFilter inserts the incoming block HTTP header filter into the database, marking as authored by provided admin account.

func (*Processor) DebugAPUrl added in v0.13.0

func (p *Processor) DebugAPUrl(
	ctx context.Context,
	adminAcct *gtsmodel.Account,
	urlStr string,
) (*apimodel.DebugAPUrlResponse, gtserror.WithCode)

DebugAPUrl performs a GET to the given url, using the signature of the given admin account. The GET will have Accept set to the ActivityPub content types.

Only urls with schema http or https are allowed.

Calls to blocked domains are not allowed, not only because it's unfair to call them when they can't call us, but because it probably won't work anyway if they try to dereference the calling account.

Errors returned from this function should be fairly verbose, to help with debugging.

func (*Processor) DeleteAllowHeaderFilter added in v0.14.0

func (p *Processor) DeleteAllowHeaderFilter(ctx context.Context, id string) gtserror.WithCode

DeleteAllowHeaderFilter deletes the allowing HTTP header filter with provided ID from the database.

func (*Processor) DeleteBlockHeaderFilter added in v0.14.0

func (p *Processor) DeleteBlockHeaderFilter(ctx context.Context, id string) gtserror.WithCode

DeleteBlockHeaderFilter deletes the blocking HTTP header filter with provided ID from the database.

func (*Processor) DomainKeysExpire added in v0.12.0

func (p *Processor) DomainKeysExpire(
	ctx context.Context,
	adminAcct *gtsmodel.Account,
	domain string,
) (string, gtserror.WithCode)

DomainKeysExpire iterates through all accounts belonging to the given domain, and expires the public key of each account found this way.

The PublicKey for each account will be re-fetched next time a signed request from that account is received.

func (*Processor) DomainPermissionCreate added in v0.12.0

func (p *Processor) DomainPermissionCreate(
	ctx context.Context,
	permissionType gtsmodel.DomainPermissionType,
	adminAcct *gtsmodel.Account,
	domain string,
	obfuscate bool,
	publicComment string,
	privateComment string,
	subscriptionID string,
) (*apimodel.DomainPermission, string, gtserror.WithCode)

DomainPermissionCreate creates an instance-level permission targeting the given domain, and then processes any side effects of the permission creation.

If the same permission type already exists for the domain, side effects will be retried.

Return values for this function are the new or existing domain permission, the ID of the admin action resulting from this call, and/or an error if something goes wrong.

func (*Processor) DomainPermissionDelete added in v0.12.0

func (p *Processor) DomainPermissionDelete(
	ctx context.Context,
	permissionType gtsmodel.DomainPermissionType,
	adminAcct *gtsmodel.Account,
	domainBlockID string,
) (*apimodel.DomainPermission, string, gtserror.WithCode)

DomainPermissionDelete removes one domain block with the given ID, and processes side effects of removing the block asynchronously.

Return values for this function are the deleted domain block, the ID of the admin action resulting from this call, and/or an error if something goes wrong.

func (*Processor) DomainPermissionGet added in v0.12.0

func (p *Processor) DomainPermissionGet(
	ctx context.Context,
	permissionType gtsmodel.DomainPermissionType,
	id string,
	export bool,
) (*apimodel.DomainPermission, gtserror.WithCode)

DomainPermissionGet returns one domain permission with the given id and type.

If export is true, the format will be suitable for writing out to an export.

func (*Processor) DomainPermissionsGet added in v0.12.0

func (p *Processor) DomainPermissionsGet(
	ctx context.Context,
	permissionType gtsmodel.DomainPermissionType,
	account *gtsmodel.Account,
	export bool,
) ([]*apimodel.DomainPermission, gtserror.WithCode)

DomainPermissionsGet returns all existing domain permissions of the requested type. If export is true, the format will be suitable for writing out to an export.

func (*Processor) DomainPermissionsImport added in v0.12.0

func (p *Processor) DomainPermissionsImport(
	ctx context.Context,
	permissionType gtsmodel.DomainPermissionType,
	account *gtsmodel.Account,
	domainsF *multipart.FileHeader,
) (*apimodel.MultiStatus, gtserror.WithCode)

DomainPermissionsImport handles the import of multiple domain permissions, by calling the DomainPermissionCreate function for each domain in the provided file. Will return a slice of processed domain permissions.

In the case of total failure, a gtserror.WithCode will be returned so that the caller can respond appropriately. In the case of partial or total success, a MultiStatus model will be returned, which contains information about success + failure count, so that the caller can retry any failures as they wish.

func (*Processor) EmailTest added in v0.8.0

func (p *Processor) EmailTest(ctx context.Context, account *gtsmodel.Account, toAddress string) gtserror.WithCode

EmailTest sends a generic test email to the given toAddress (which should be a valid email address). To help callers differentiate between proper errors and the smtp errors they're likely fishing for, will return 422 + help text on an SMTP error, or error 500 otherwise.

func (*Processor) EmojiCategoriesGet added in v0.6.0

func (p *Processor) EmojiCategoriesGet(
	ctx context.Context,
) ([]*apimodel.EmojiCategory, gtserror.WithCode)

EmojiCategoriesGet returns all custom emoji categories that exist on this instance.

func (*Processor) EmojiCreate

func (p *Processor) EmojiCreate(
	ctx context.Context,
	account *gtsmodel.Account,
	form *apimodel.EmojiCreateRequest,
) (*apimodel.Emoji, gtserror.WithCode)

EmojiCreate creates a custom emoji on this instance.

func (*Processor) EmojiDelete added in v0.6.0

func (p *Processor) EmojiDelete(
	ctx context.Context,
	id string,
) (*apimodel.AdminEmoji, gtserror.WithCode)

EmojiDelete deletes one *local* emoji from the database, with the given id.

func (*Processor) EmojiGet added in v0.6.0

func (p *Processor) EmojiGet(
	ctx context.Context,
	account *gtsmodel.Account,
	id string,
) (*apimodel.AdminEmoji, gtserror.WithCode)

EmojiGet returns the admin view of one custom emoji with the given id.

func (*Processor) EmojiUpdate added in v0.6.0

EmojiUpdate updates one emoji with the given id, using the provided form parameters.

func (*Processor) EmojisGet added in v0.6.0

func (p *Processor) EmojisGet(
	ctx context.Context,
	account *gtsmodel.Account,
	domain string,
	includeDisabled bool,
	includeEnabled bool,
	shortcode string,
	maxShortcodeDomain string,
	minShortcodeDomain string,
	limit int,
) (*apimodel.PageableResponse, gtserror.WithCode)

EmojisGet returns an admin view of custom emojis, filtered with the given parameters.

func (*Processor) GetAllowHeaderFilter added in v0.14.0

func (p *Processor) GetAllowHeaderFilter(ctx context.Context, id string) (*apimodel.HeaderFilter, gtserror.WithCode)

GetAllowHeaderFilter fetches allow HTTP header filter with provided ID from the database.

func (*Processor) GetAllowHeaderFilters added in v0.14.0

func (p *Processor) GetAllowHeaderFilters(ctx context.Context) ([]*apimodel.HeaderFilter, gtserror.WithCode)

GetAllowHeaderFilters fetches all allow HTTP header filters stored in the database.

func (*Processor) GetBlockHeaderFilter added in v0.14.0

func (p *Processor) GetBlockHeaderFilter(ctx context.Context, id string) (*apimodel.HeaderFilter, gtserror.WithCode)

GetBlockHeaderFilter fetches block HTTP header filter with provided ID from the database.

func (*Processor) GetBlockHeaderFilters added in v0.14.0

func (p *Processor) GetBlockHeaderFilters(ctx context.Context) ([]*apimodel.HeaderFilter, gtserror.WithCode)

GetBlockHeaderFilters fetches all block HTTP header filters stored in the database.

func (*Processor) MediaPrune added in v0.3.4

func (p *Processor) MediaPrune(ctx context.Context, mediaRemoteCacheDays int) gtserror.WithCode

MediaPrune triggers a non-blocking prune of unused media, orphaned, uncaching remote and fixing cache states.

func (*Processor) MediaRefetch added in v0.7.0

func (p *Processor) MediaRefetch(ctx context.Context, requestingAccount *gtsmodel.Account, domain string) gtserror.WithCode

MediaRefetch forces a refetch of remote emojis.

func (*Processor) ReportGet added in v0.7.0

func (p *Processor) ReportGet(ctx context.Context, account *gtsmodel.Account, id string) (*apimodel.AdminReport, gtserror.WithCode)

ReportGet returns one report, with the given ID.

func (*Processor) ReportResolve added in v0.7.0

func (p *Processor) ReportResolve(ctx context.Context, account *gtsmodel.Account, id string, actionTakenComment *string) (*apimodel.AdminReport, gtserror.WithCode)

ReportResolve marks a report with the given id as resolved, and stores the provided actionTakenComment (if not null). If the report creator is from this instance, an email will be sent to them to let them know that the report is resolved.

func (*Processor) ReportsGet added in v0.7.0

func (p *Processor) ReportsGet(
	ctx context.Context,
	account *gtsmodel.Account,
	resolved *bool,
	accountID string,
	targetAccountID string,
	maxID string,
	sinceID string,
	minID string,
	limit int,
) (*apimodel.PageableResponse, gtserror.WithCode)

ReportsGet returns all reports stored on this instance, with the given parameters.

func (*Processor) RuleCreate added in v0.12.0

RuleCreate adds a new rule to the instance.

func (*Processor) RuleDelete added in v0.12.0

RuleDelete deletes an existing rule.

func (*Processor) RuleGet added in v0.12.0

RuleGet returns one rule, with the given ID.

func (*Processor) RuleUpdate added in v0.12.0

RuleUpdate updates text for an existing rule.

func (*Processor) RulesGet added in v0.12.0

RulesGet returns all rules stored on this instance.

Jump to

Keyboard shortcuts

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