status

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TopoSort added in v0.14.0

func TopoSort(apiStatuses []*apimodel.Status, targetAccountID string)

TopoSort sorts statuses topologically, by self-reply, and by ID. Can handle cycles but the output order will be arbitrary. (But if there are cycles, something went wrong upstream.)

Types

type Processor

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

func New

func New(
	state *state.State,
	common *common.Processor,
	polls *polls.Processor,
	federator *federation.Federator,
	converter *typeutils.Converter,
	filter *visibility.Filter,
	parseMention gtsmodel.ParseMentionFunc,
) Processor

New returns a new status processor.

func (*Processor) BookmarkCreate added in v0.8.0

func (p *Processor) BookmarkCreate(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

BookmarkCreate adds a bookmark for the requestingAccount, targeting the given status (no-op if bookmark already exists).

func (*Processor) BookmarkRemove added in v0.8.0

func (p *Processor) BookmarkRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

BookmarkRemove removes a bookmark for the requesting account, targeting the given status (no-op if bookmark doesn't exist).

func (*Processor) BoostCreate added in v0.8.0

func (p *Processor) BoostCreate(
	ctx context.Context,
	requester *gtsmodel.Account,
	application *gtsmodel.Application,
	targetID string,
) (*apimodel.Status, gtserror.WithCode)

BoostCreate processes the boost/reblog of target status, returning the newly-created boost.

func (*Processor) BoostRemove added in v0.8.0

func (p *Processor) BoostRemove(
	ctx context.Context,
	requester *gtsmodel.Account,
	application *gtsmodel.Application,
	targetID string,
) (*apimodel.Status, gtserror.WithCode)

BoostRemove processes the unboost/unreblog of target status, returning the target status.

func (*Processor) ContextGet added in v0.8.0

func (p *Processor) ContextGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Context, gtserror.WithCode)

ContextGet returns the context (previous and following posts) from the given status ID.

func (*Processor) Create

Create processes the given form to create a new status, returning the api model representation of that status if it's OK.

Precondition: the form's fields should have already been validated and normalized by the caller.

func (*Processor) Delete

func (p *Processor) Delete(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

Delete processes the delete of a given status, returning the deleted status if the delete goes through.

func (*Processor) FaveCreate added in v0.8.0

func (p *Processor) FaveCreate(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

FaveCreate adds a fave for the requestingAccount, targeting the given status (no-op if fave already exists).

func (*Processor) FaveRemove added in v0.8.0

func (p *Processor) FaveRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

FaveRemove removes a fave for the requesting account, targeting the given status (no-op if fave doesn't exist).

func (*Processor) FavedBy

func (p *Processor) FavedBy(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) ([]*apimodel.Account, gtserror.WithCode)

FavedBy returns a slice of accounts that have liked the given status, filtered according to privacy settings.

func (*Processor) Get

func (p *Processor) Get(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

Get gets the given status, taking account of privacy settings and blocks etc.

func (*Processor) MuteCreate added in v0.13.0

func (p *Processor) MuteCreate(
	ctx context.Context,
	requestingAccount *gtsmodel.Account,
	targetStatusID string,
) (*apimodel.Status, gtserror.WithCode)

func (*Processor) MuteRemove added in v0.13.0

func (p *Processor) MuteRemove(
	ctx context.Context,
	requestingAccount *gtsmodel.Account,
	targetStatusID string,
) (*apimodel.Status, gtserror.WithCode)

func (*Processor) PinCreate added in v0.8.0

func (p *Processor) PinCreate(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

PinCreate pins the target status to the top of requestingAccount's profile, if possible.

Conditions for a pin to work:

  • Status belongs to requesting account.
  • Status is public, unlisted, or followers-only.
  • Status is not a boost.
  • Status is not already pinnd.
  • Limit of pinned statuses not yet met or exceeded.

If the conditions can't be met, then code 422 Unprocessable Entity will be returned.

func (*Processor) PinRemove added in v0.8.0

func (p *Processor) PinRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

PinRemove unpins the target status from the top of requestingAccount's profile, if possible.

Conditions for an unpin to work:

  • Status belongs to requesting account.
  • Status is public, unlisted, or followers-only.
  • Status is not a boost.

If the conditions can't be met, then code 422 Unprocessable Entity will be returned.

Unlike with PinCreate, statuses that are already unpinned will not return 422, but just do nothing and return the api model representation of the status, to conform to the masto API.

func (*Processor) StatusBoostedBy added in v0.8.0

func (p *Processor) StatusBoostedBy(ctx context.Context, requestingAccount *gtsmodel.Account, targetStatusID string) ([]*apimodel.Account, gtserror.WithCode)

StatusBoostedBy returns a slice of accounts that have boosted the given status, filtered according to privacy settings.

func (*Processor) WebContextGet added in v0.13.0

func (p *Processor) WebContextGet(ctx context.Context, targetStatusID string) (*apimodel.Context, gtserror.WithCode)

WebContextGet is like ContextGet, but is explicitly for viewing statuses via the unauthenticated web UI.

TODO: a more advanced threading model could be implemented here.

func (*Processor) WebGet added in v0.13.0

func (p *Processor) WebGet(ctx context.Context, targetStatusID string) (*apimodel.Status, gtserror.WithCode)

WebGet gets the given status for web use, taking account of privacy settings.

Jump to

Keyboard shortcuts

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