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

Merge pull request #61 from matrix-org/matthew/accountdata

implement account data
This commit is contained in:
Matthew Hodgson
2016-01-13 12:43:53 +00:00
3 changed files with 96 additions and 8 deletions

View File

@@ -742,6 +742,43 @@ 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.authedRequestWithPrefix(
callback, "PUT", path, undefined, content, httpApi.PREFIX_V2_ALPHA
);
};
/**
* @param {string} roomId
* @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.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
@@ -1810,7 +1847,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");
};
/**