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. |
Classes
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. |
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. |
# 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. |