Class

ProfileCache

ProfileCache(maxEntries, maxAgeMs, client)

Functions for avoiding calls to profile endpoints. Useful for bots when people are mentioned often or bridges which need profile information often.
Constructor

# new ProfileCache(maxEntries, maxAgeMs, client)

Creates a new profile cache.
Parameters:
Name Type Description
maxEntries number The maximum number of entries to cache.
maxAgeMs number The maximum age of an entry in milliseconds.
client MatrixClient The client to use to get profile updates.

View Source helpers/ProfileCache.ts, line 11

Classes

ProfileCache
ProfileCache

Methods

# async getUserProfile(userId, roomId) → {Promise.<MatrixProfile>}

Gets a profile for a user in optional room.
Parameters:
Name Type Description
userId string The user ID to get a profile for.
roomId string | null Optional room ID to get a per-room profile for the user.

View Source helpers/ProfileCache.ts, line 161

Resolves to the user's profile.
Promise.<MatrixProfile>

# watchWithAppservice(appservice, clientFn)

Watch for profile changes to cached entries with the provided application service. The clientFn will be called to get the relevant client for any updates. If the clientFn is null, the appservice's bot user will be used. The clientFn takes two arguments: the user ID being updated and the room ID they are being updated in (shouldn't be null). The return value should be the MatrixClient to use, or null to use the appservice's bot client. The same client will be used to update the user's general profile, if that profile is cached.
Parameters:
Name Type Description
appservice Appservice The application service to watch for profile changes with.
clientFn function The function to use to acquire profile updates with. If null, the appservice's bot client will be used.

View Source helpers/ProfileCache.ts, line 151

# watchWithClient(client)

Watch for profile changes to cached entries with the provided client. The same client will also be used to update the user's profile in the cache.
Parameters:
Name Type Description
client MatrixClient The client to watch for profile changes with.

View Source helpers/ProfileCache.ts, line 136