You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
generic account data support
This commit is contained in:
@@ -903,6 +903,37 @@ MatrixClient.prototype.getUsers = function() {
|
||||
return this.store.getUsers();
|
||||
};
|
||||
|
||||
// User Account Data operations
|
||||
// ============================
|
||||
|
||||
/**
|
||||
* Set account data event for the current user.
|
||||
* @param {string} eventType The event type
|
||||
* @param {Object} the contents object for the event
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.setAccountData = function(eventType, contents, callback) {
|
||||
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
||||
$userId: this.credentials.userId,
|
||||
$type: eventType,
|
||||
});
|
||||
return this._http.authedRequest(
|
||||
callback, "PUT", path, undefined, contents
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get account data event of given type for the current user.
|
||||
* @param {string} eventType The event type
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {?object} The contents of the given account data event
|
||||
*/
|
||||
MatrixClient.prototype.getAccountData = function(eventType) {
|
||||
return this.store.getAccountData(eventType);
|
||||
};
|
||||
|
||||
// Room operations
|
||||
// ===============
|
||||
|
||||
@@ -1086,23 +1117,6 @@ MatrixClient.prototype.deleteRoomTag = function(roomId, tagName, callback) {
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} eventType event type to be set
|
||||
* @param {object} content event content
|
||||
* @param {module:client.callback} callback Optional.
|
||||
* @return {module:client.Promise} Resolves: TODO
|
||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
||||
*/
|
||||
MatrixClient.prototype.setAccountData = function(eventType, content, callback) {
|
||||
var path = utils.encodeUri("/user/$userId/account_data/$type", {
|
||||
$userId: this.credentials.userId,
|
||||
$type: eventType,
|
||||
});
|
||||
return this._http.authedRequest(
|
||||
callback, "PUT", path, undefined, content
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} roomId
|
||||
* @param {string} eventType event type to be set
|
||||
@@ -3991,7 +4005,7 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
||||
* });
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Fires when a device is marked as verified/unverified/blocked/unblocked by
|
||||
* {@link module:client~MatrixClient#setDeviceVerified|MatrixClient.setDeviceVerified} or
|
||||
* {@link module:client~MatrixClient#setDeviceBlocked|MatrixClient.setDeviceBlocked}.
|
||||
@@ -4001,6 +4015,17 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
||||
* @param {module:client~DeviceInfo} device information about the verified device
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fires whenever new user-scoped account_data is added.
|
||||
* @event module:client~MatrixClient#"Room"
|
||||
* @param {MatrixEvent} event The event describing the account_data just added
|
||||
* @example
|
||||
* matrixClient.on("accountData", function(event){
|
||||
* myAccountData[event.type] = event.content;
|
||||
* });
|
||||
*/
|
||||
|
||||
|
||||
// EventEmitter JSDocs
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user