account

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: 43 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(
	common *common.Processor,
	state *state.State,
	converter *typeutils.Converter,
	mediaManager *media.Manager,
	oauthServer oauth.Server,
	federator *federation.Federator,
	filter *visibility.Filter,
	parseMention gtsmodel.ParseMentionFunc,
) Processor

New returns a new account processor.

func (*Processor) Alias added in v0.14.0

func (p *Processor) Alias(
	ctx context.Context,
	account *gtsmodel.Account,
	newAKAURIStrs []string,
) (*apimodel.Account, gtserror.WithCode)

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) BlocksGet added in v0.12.0

func (p *Processor) BlocksGet(
	ctx context.Context,
	requestingAccount *gtsmodel.Account,
	page *paging.Page,
) (*apimodel.PageableResponse, gtserror.WithCode)

BlocksGet ...

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,
	appToken oauth2.TokenInfo,
	app *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.

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,
	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) FollowRequestAccept added in v0.12.0

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

FollowRequestAccept handles the accepting of a follow request from the sourceAccountID to the requestingAccount (the currently authorized account).

func (*Processor) FollowRequestReject added in v0.12.0

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

FollowRequestReject handles the rejection of a follow request from the sourceAccountID to the requestingAccount (the currently authorized account).

func (*Processor) FollowRequestsGet added in v0.12.0

func (p *Processor) FollowRequestsGet(ctx context.Context, requestingAccount *gtsmodel.Account, page *paging.Page) (*apimodel.PageableResponse, gtserror.WithCode)

FollowRequestsGet fetches a list of the accounts that are follow requesting the given requestingAccount (the currently authorized account).

func (*Processor) FollowersGet

func (p *Processor) FollowersGet(ctx context.Context, requestingAccount *gtsmodel.Account, targetAccountID string, page *paging.Page) (*apimodel.PageableResponse, 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, page *paging.Page) (*apimodel.PageableResponse, 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) MoveSelf added in v0.14.0

func (p *Processor) MoveSelf(
	ctx context.Context,
	authed *oauth.Auth,
	form *apimodel.AccountMoveRequest,
) gtserror.WithCode

func (*Processor) PutNote added in v0.11.0

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

PutNote updates the requesting account's private note on the target account.

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) ThemesGet added in v0.15.0

func (p *Processor) ThemesGet() []apimodel.Theme

GetThemes returns available account css themes.

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 media, and doing the necessary updates in the database for this to become the account's new avatar.

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 media, and doing the necessary updates in the database for this to become the account's new header.

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.

func (*Processor) WebStatusesGetPinned added in v0.13.0

func (p *Processor) WebStatusesGetPinned(
	ctx context.Context,
	targetAccountID string,
) ([]*apimodel.Status, gtserror.WithCode)

WebStatusesGetPinned returns web versions of pinned statuses.

type Themes added in v0.15.0

type Themes struct {
	// Themes sorted alphabetically
	// by title (case insensitive).
	SortedByTitle []*gtsmodel.Theme

	// ByFileName contains themes retrievable
	// by their filename eg., `light-blurple.css`.
	ByFileName map[string]*gtsmodel.Theme
}

Themes represents an in-memory storage structure for themes.

func PopulateThemes added in v0.15.0

func PopulateThemes() *Themes

PopulateThemes parses available account CSS themes from the web assets themes directory.

Jump to

Keyboard shortcuts

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