account

package
v0.10.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetRSSFeed added in v0.10.0

type GetRSSFeed func() (string, gtserror.WithCode)

type Processor

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

Processor wraps functionality for updating, creating, and deleting accounts in response to API requests.

It also contains logic for actions towards accounts such as following, blocking, seeing follows, etc.

func New

func New(
	state *state.State,
	tc typeutils.TypeConverter,
	mediaManager *media.Manager,
	oauthServer oauth.Server,
	federator federation.Federator,
	filter *visibility.Filter,
	parseMention gtsmodel.ParseMentionFunc,
) Processor

New returns a new account processor.

func (*Processor) BlockCreate

func (p *Processor) BlockCreate(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode)

BlockCreate handles the creation of a block from requestingAccount to targetAccountID, either remote or local.

func (*Processor) BlockRemove

func (p *Processor) BlockRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode)

BlockRemove handles the removal of a block from requestingAccount to targetAccountID, either remote or local.

func (*Processor) BookmarksGet added in v0.7.0

func (p *Processor) BookmarksGet(ctx context.Context, requestingAccount *gtsmodel.Account, limit int, maxID string, minID string) (*apimodel.PageableResponse, gtserror.WithCode)

BookmarksGet returns a pageable response of statuses that are bookmarked by requestingAccount. Paging for this response is done based on bookmark ID rather than status ID.

func (*Processor) Create

func (p *Processor) Create(ctx context.Context, applicationToken oauth2.TokenInfo, application *gtsmodel.Application, form *apimodel.AccountCreateRequest) (*apimodel.Token, gtserror.WithCode)

Create processes the given form for creating a new account, returning an oauth token for that account if successful.

func (*Processor) Delete

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

Delete deletes an account, and all of that account's statuses, media, follows, notifications, etc etc etc. The origin passed here should be either the ID of the account doing the delete (can be itself), or the ID of a domain block.

func (*Processor) DeleteSelf added in v0.8.0

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

DeleteSelf is like Delete, but specifically for local accounts deleting themselves.

Calling DeleteSelf results in a delete message being enqueued in the processor, which causes side effects to occur: delete will be federated out to other instances, and the above Delete function will be called afterwards from the processor, to clear out the account's bits and bobs, and stubbify it.

func (*Processor) FollowCreate

func (p *Processor) FollowCreate(ctx context.Context, requestingAccount *gtsmodel.Account, form *apimodel.AccountFollowRequest) (*apimodel.Relationship, gtserror.WithCode)

FollowCreate handles a follow request to an account, either remote or local.

func (*Processor) FollowRemove

func (p *Processor) FollowRemove(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode)

FollowRemove handles the removal of a follow/follow request to an account, either remote or local.

func (*Processor) FollowersGet

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

FollowersGet fetches a list of the target account's followers.

func (*Processor) FollowingGet

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

FollowingGet fetches a list of the accounts that target account is following.

func (*Processor) Get

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

Get processes the given request for account information.

func (*Processor) GetCustomCSSForUsername added in v0.5.0

func (p *Processor) GetCustomCSSForUsername(ctx context.Context, username string) (string, gtserror.WithCode)

GetCustomCSSForUsername returns custom css for the given local username.

func (*Processor) GetLocalByUsername added in v0.3.0

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

GetLocalByUsername processes the given request for account information targeting a local account by username.

func (*Processor) GetRSSFeedForUsername added in v0.6.0

func (p *Processor) GetRSSFeedForUsername(ctx context.Context, username string) (GetRSSFeed, time.Time, gtserror.WithCode)

GetRSSFeedForUsername returns a function to return the RSS feed of a local account with the given username, and the last-modified time (time that the account last posted a status eligible to be included in the rss feed).

To save db calls, callers to this function should only call the returned GetRSSFeed func if the last-modified time is newer than the last-modified time they have cached.

If the account has not yet posted an RSS-eligible status, the returned last-modified time will be zero, and the GetRSSFeed func will return a valid RSS xml with no items.

func (*Processor) ListsGet added in v0.10.0

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

ListsGet returns all lists owned by requestingAccount, which contain a follow for targetAccountID.

func (*Processor) PinnedStatusesGet added in v0.10.0

func (p *Processor) PinnedStatusesGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.PageableResponse, gtserror.WithCode)

PinnedStatusesGet is a shortcut for getting just an account's pinned statuses. Under the hood, it just calls StatusesGet using mostly default parameters.

func (*Processor) RelationshipGet

func (p *Processor) RelationshipGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string) (*apimodel.Relationship, gtserror.WithCode)

RelationshipGet returns a relationship model describing the relationship of the targetAccount to the Authed account.

func (*Processor) StatusesGet

func (p *Processor) StatusesGet(
	ctx context.Context,
	requestingAccount *gtsmodel.Account,
	targetAccountID string,
	limit int,
	excludeReplies bool,
	excludeReblogs bool,
	maxID string,
	minID string,
	pinned bool,
	mediaOnly bool,
	publicOnly bool,
) (*apimodel.PageableResponse, gtserror.WithCode)

StatusesGet fetches a number of statuses (in time descending order) from the target account, filtered by visibility according to the requesting account.

func (*Processor) Update

Update processes the update of an account with the given form.

func (*Processor) UpdateAvatar

func (p *Processor) UpdateAvatar(ctx context.Context, avatar *multipart.FileHeader, description *string, accountID string) (*gtsmodel.MediaAttachment, error)

UpdateAvatar does the dirty work of checking the avatar part of an account update form, parsing and checking the image, and doing the necessary updates in the database for this to become the account's new avatar image.

func (*Processor) UpdateHeader

func (p *Processor) UpdateHeader(ctx context.Context, header *multipart.FileHeader, description *string, accountID string) (*gtsmodel.MediaAttachment, error)

UpdateHeader does the dirty work of checking the header part of an account update form, parsing and checking the image, and doing the necessary updates in the database for this to become the account's new header image.

func (*Processor) WebStatusesGet added in v0.3.8

func (p *Processor) WebStatusesGet(ctx context.Context, targetAccountID string, maxID string) (*apimodel.PageableResponse, gtserror.WithCode)

WebStatusesGet fetches a number of statuses (in descending order) from the given account. It selects only statuses which are suitable for showing on the public web profile of an account.

Jump to

Keyboard shortcuts

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