dereferencing

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 6 hours.
	//
	// Default window for doing a
	// fresh dereference of an Account.
	DefaultAccountFreshness = util.Ptr(FreshnessWindow(6 * time.Hour))

	// 2 hours.
	//
	// Default window for doing a
	// fresh dereference of a Status.
	DefaultStatusFreshness = util.Ptr(FreshnessWindow(2 * time.Hour))

	// 5 minutes.
	//
	// Fresh is useful when you're wanting
	// a more up-to-date model of something
	// that exceeds default freshness windows.
	//
	// This is tuned to be quite fresh without
	// causing loads of dereferencing calls.
	Fresh = util.Ptr(FreshnessWindow(5 * time.Minute))

	// 10 seconds.
	//
	// Freshest is useful when you want an
	// immediately up to date model of something
	// that's even fresher than Fresh.
	//
	// Be careful using this one; it can cause
	// lots of unnecessary traffic if used unwisely.
	Freshest = util.Ptr(FreshnessWindow(10 * time.Second))
)

Functions

This section is empty.

Types

type Dereferencer

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

Dereferencer wraps logic and functionality for doing dereferencing of remote accounts, statuses, etc, from federated instances.

func NewDereferencer

func NewDereferencer(
	state *state.State,
	converter *typeutils.Converter,
	transportController transport.Controller,
	visFilter *visibility.Filter,
	mediaManager *media.Manager,
) Dereferencer

NewDereferencer returns a Dereferencer initialized with the given parameters.

func (*Dereferencer) DereferenceStatusAncestors added in v0.10.0

func (d *Dereferencer) DereferenceStatusAncestors(ctx context.Context, username string, status *gtsmodel.Status) error

DereferenceStatusAncestors iterates upwards from the given status, using InReplyToURI, to ensure that as many parent statuses as possible are dereferenced.

func (*Dereferencer) DereferenceStatusDescendants added in v0.10.0

func (d *Dereferencer) DereferenceStatusDescendants(ctx context.Context, username string, statusIRI *url.URL, parent ap.Statusable) error

DereferenceStatusDescendents iterates downwards from the given status, using its replies, to ensure that as many children statuses as possible are dereferenced.

func (*Dereferencer) EnrichAnnounce added in v0.13.0

func (d *Dereferencer) EnrichAnnounce(
	ctx context.Context,
	boost *gtsmodel.Status,
	requestUser string,
) (*gtsmodel.Status, error)

EnrichAnnounce enriches the given boost wrapper status by either fetching from the DB or dereferencing the target status, populating the boost wrapper's fields based on the target status, and then storing the wrapper in the database. The wrapper is then returned to the caller.

The provided boost wrapper status must have BoostOfURI set.

func (*Dereferencer) GetAccountByURI added in v0.7.0

func (d *Dereferencer) GetAccountByURI(ctx context.Context, requestUser string, uri *url.URL) (*gtsmodel.Account, ap.Accountable, error)

GetAccountByURI will attempt to fetch an accounts by its URI, first checking the database. In the case of a newly-met remote model, or a remote model whose last_fetched date is beyond a certain interval, the account will be dereferenced. In the case of dereferencing, some low-priority account information may be enqueued for asynchronous fetching, e.g. featured account statuses (pins). An ActivityPub object indicates the account was dereferenced.

func (*Dereferencer) GetAccountByUsernameDomain added in v0.7.0

func (d *Dereferencer) GetAccountByUsernameDomain(ctx context.Context, requestUser string, username string, domain string) (*gtsmodel.Account, ap.Accountable, error)

GetAccountByUsernameDomain will attempt to fetch an accounts by its username@domain, first checking the database. In the case of a newly-met remote model, or a remote model whose last_fetched date is beyond a certain interval, the account will be dereferenced. In the case of dereferencing, some low-priority account information may be enqueued for asynchronous fetching, e.g. featured account statuses (pins). An ActivityPub object indicates the account was dereferenced.

func (*Dereferencer) GetRemoteEmoji added in v0.5.0

func (d *Dereferencer) GetRemoteEmoji(ctx context.Context, requestingUsername string, remoteURL string, shortcode string, domain string, id string, emojiURI string, ai *media.AdditionalEmojiInfo, refresh bool) (*media.ProcessingEmoji, error)

func (*Dereferencer) GetRemoteInstance

func (d *Dereferencer) GetRemoteInstance(ctx context.Context, username string, remoteInstanceURI *url.URL) (*gtsmodel.Instance, error)

func (*Dereferencer) GetStatusByURI added in v0.9.0

func (d *Dereferencer) GetStatusByURI(ctx context.Context, requestUser string, uri *url.URL) (*gtsmodel.Status, ap.Statusable, error)

GetStatusByURI will attempt to fetch a status by its URI, first checking the database. In the case of a newly-met remote model, or a remote model whose 'last_fetched' date is beyond a certain interval, the status will be dereferenced. In the case of dereferencing, some low-priority status information may be enqueued for asynchronous fetching, e.g. dereferencing the status thread. Param 'syncParent' = true indicates to fetch status ancestors synchronously. An ActivityPub object indicates the status was dereferenced.

func (*Dereferencer) Handshaking

func (d *Dereferencer) Handshaking(username string, remoteAccountID *url.URL) bool

func (*Dereferencer) RefreshAccount added in v0.9.0

func (d *Dereferencer) RefreshAccount(
	ctx context.Context,
	requestUser string,
	account *gtsmodel.Account,
	accountable ap.Accountable,
	window *FreshnessWindow,
) (*gtsmodel.Account, ap.Accountable, error)

RefreshAccount updates the given account if it's a remote account, and considered stale / not fresh based on Account.FetchedAt and desired freshness.

An updated account model is returned, but in the case of dereferencing, some low-priority account info may be enqueued for asynchronous fetching, e.g. featured account statuses (pins).

An ActivityPub object indicates the account was dereferenced (i.e. updated).

func (*Dereferencer) RefreshAccountAsync added in v0.9.0

func (d *Dereferencer) RefreshAccountAsync(
	ctx context.Context,
	requestUser string,
	account *gtsmodel.Account,
	accountable ap.Accountable,
	window *FreshnessWindow,
)

RefreshAccountAsync enqueues the given account for an asychronous update fetching, if it's a remote account, and considered stale / not fresh based on Account.FetchedAt and desired freshness.

This is a more optimized form of manually enqueueing .UpdateAccount() to the federation worker, since it only enqueues update if necessary.

func (*Dereferencer) RefreshStatus added in v0.9.0

func (d *Dereferencer) RefreshStatus(
	ctx context.Context,
	requestUser string,
	status *gtsmodel.Status,
	statusable ap.Statusable,
	window *FreshnessWindow,
) (*gtsmodel.Status, ap.Statusable, error)

RefreshStatus is functionally equivalent to GetStatusByURI(), except that it requires a pre populated status model (with AT LEAST uri set), and ALL thread dereferencing is asynchronous.

func (*Dereferencer) RefreshStatusAsync added in v0.9.0

func (d *Dereferencer) RefreshStatusAsync(
	ctx context.Context,
	requestUser string,
	status *gtsmodel.Status,
	statusable ap.Statusable,
	window *FreshnessWindow,
)

RefreshStatusAsync is functionally equivalent to RefreshStatus(), except that ALL dereferencing is queued for asynchronous processing, (both thread AND status).

type FreshnessWindow added in v0.14.0

type FreshnessWindow time.Duration

FreshnessWindow represents a duration in which a Status or Account is still considered to be "fresh" (ie., not in need of a refresh from remote), if its last FetchedAt value falls within the window.

For example, if an Account was FetchedAt 09:00, and it is now 12:00, then it would be considered "fresh" according to DefaultAccountFreshness, but not according to Fresh, which would indicate that the Account requires refreshing from remote.

Jump to

Keyboard shortcuts

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