Skip to content

Commit

Permalink
Add API to get account data from server
Browse files Browse the repository at this point in the history
This adds an API account data getter that bypasses the local store and goes
directly to the homeserver.

Part of element-hq/element-web#11214
  • Loading branch information
jryans committed Jan 15, 2020
1 parent 04bbfae commit c5c27b3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,25 @@ MatrixClient.prototype.getAccountData = function(eventType) {
return this.store.getAccountData(eventType);
};

/**
* Get account data event of given type for the current user. This variant
* bypasses the local store and gets account data directly from the homeserver,
* which can be useful very early in startup before the initial sync.
* @param {string} eventType The event type
* @return {module:client.Promise} Resolves: The contents of the given account
* data event.
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.getAccountDataFromServer = function(eventType) {
const path = utils.encodeUri("/user/$userId/account_data/$type", {
$userId: this.credentials.userId,
$type: eventType,
});
return this._http.authedRequest(
undefined, "GET", path, undefined,
);
};

/**
* Gets the users that are ignored by this client
* @returns {string[]} The array of users that are ignored (empty if none)
Expand Down

0 comments on commit c5c27b3

Please sign in to comment.