Class: UserData

UserData()

Represents background and scoring-related data about the current Fedialgo user. Used as a central source of user context for scoring, filtering, and personalization. This class aggregates and manages user-related data such as favourited accounts, followed tags, muted accounts, languages posted in, and server-side filters. It provides methods to build user data from the Mastodon API or from raw API data, and supports updating, counting, and filtering operations for use in scoring and filtering algorithms.

Constructor

new UserData()

Properties:
Name Type Description
blockedDomains Set.<string> Set of domains the user has blocked.
favouriteAccounts BooleanFilterOptionList Accounts the user has favourited, retooted, or replied to.
favouritedTags TagList List of tags the user has favourited.
followedAccounts StringNumberDict Dictionary of accounts the user follows, keyed by account name.
followedTags TagList List of tags the user follows.
isRetooter boolean True if the user is primarily a retooter (retootPct above configured threshold).
languagesPostedIn ObjList List of languages the user has posted in, with usage counts.
mutedAccounts Record.<string, Account> Dictionary of accounts the user has muted or blocked, keyed by Account["webfingerURI"].
mutedKeywordsRegex RegExp Cached regex for muted keywords, built from server-side filters.
participatedTags TagList List of tags the user has participated in.
preferredLanguage string The user's preferred language (ISO code).
serverSideFilters Array.<mastodon.v2.Filter> Array of server-side filters set by the user.

Methods

(async) hasNewestApiData() → {Promise.<boolean>}

If there's newer data in the cache the data is not fresh.
Returns:
True if UserData object was created after the last updatedAt in Storage.
Type
Promise.<boolean>

(async, static) build() → {Promise.<module:api/user_data~UserData>}

Alternate constructor for the UserData object to build itself from the API (or cache).
Returns:
UserData instance populated with the user's data.
Type
Promise.<module:api/user_data~UserData>

(static) buildFromData(data) → {module:api/user_data~UserData}

Alternate constructor to build UserData from API data.
Parameters:
Name Type Description
data UserApiData The raw API data to build the UserData from.
Properties
Name Type Description
blockedDomains Array.<string> Domains the user has blocked.
favouritedToots Array.<Toot> Toots the user has favourited.
followedAccounts Array.<Account> Accounts the user follows.
followedTags Array.<TagWithUsageCounts> Tags the user follows, with usage counts.
mutedAccounts Array.<Account> Accounts the user has muted.
recentToots Array.<Toot> Recent toots by the user.*
serverSideFilters Array.<mastodon.v2.Filter> Server-side filters set by the user.
Returns:
A new UserData instance populated with the provided data.
Type
module:api/user_data~UserData

(async, static) getMutedKeywords() → {Promise.<Array.<string>>}

Get an array of keywords the user has muted on the server side
Returns:
An array of muted keywords.
Type
Promise.<Array.<string>>

(async, static) getMutedKeywordsRegex() → {Promise.<RegExp>}

Build a regex that matches any of the user's muted keywords.
Returns:
A RegExp that matches any of the user's muted keywords.
Type
Promise.<RegExp>