1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00

implement account data

This commit is contained in:
Matthew Hodgson
2016-01-08 03:22:08 +00:00
parent 446faed9b5
commit 387ad09c5f
4 changed files with 103 additions and 11 deletions

View File

@@ -722,6 +722,42 @@ MatrixClient.prototype.deleteRoomTag = function(roomId, tagName, callback) {
);
};
/**
* @param {MatrixEvent} account_data event
* @param {string} event type to be set
* @param {object} content event content
* @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.setAccountData = function(event, eventType, content) {
var path = utils.encodeUri("/user/$userId/account_data/$type", {
$userId: this.credentials.userId,
$type: event.getType(),
});
return this._http.authedRequestWithPrefix(
callback, "PUT", path, undefined, content, httpApi.PREFIX_V2_ALPHA
);
};
/**
* @param {string} roomId
* @param {string} 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.setRoomAccountData = function(roomId, eventType, content, callback) {
var path = utils.encodeUri("/user/$userId/rooms/$roomId/account_data/$type", {
$userId: this.credentials.userId,
$roomId: roomId,
$type: eventType,
});
return this._http.authedRequestWithPrefix(
callback, "PUT", path, undefined, content, httpApi.PREFIX_V2_ALPHA
);
};
/**
* Set a user's power level.
* @param {string} roomId
@@ -1782,7 +1818,7 @@ MatrixClient.prototype.setPresence = function(presence, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.publicRooms = function(callback) {
return this._http.request(callback, "GET", "/publicRooms");
return this._http.authedRequest(callback, "GET", "/publicRooms");
};
/**