1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-18 05:42:00 +03:00

fix some review feedback; add initial api for setting & deleting tags; still a WIP

This commit is contained in:
Matthew Hodgson
2015-11-04 02:24:36 +00:00
parent 5a1cc4c2e7
commit 149ed04a4f
2 changed files with 41 additions and 4 deletions

View File

@@ -608,6 +608,43 @@ MatrixClient.prototype.setRoomTopic = function(roomId, topic, callback) {
undefined, callback);
};
/**
* @param {string} roomId
* @param {string} name of room tag to be set
* @param {object} metadata associated with that tag to be stored
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.setRoomTag = function(roomId, tagName, metadata, callback) {
var path = utils.encodeUri("/user/$userId/rooms/$roomId/tags/$tag", {
$userId: this.credentials.userId,
$roomId: roomId,
$tag: tagName,
});
return this._http.authedRequestWithPrefix(
callback, "PUT", path, undefined, metadata, httpApi.PREFIX_V2_ALPHA
);
};
/**
* @param {string} roomId
* @param {string} name of room tag to be removed
* @param {module:client.callback} callback Optional.
* @return {module:client.Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixClient.prototype.deleteRoomTag = function(roomId, tagName, callback) {
var path = utils.encodeUri("/user/$userId/rooms/$roomId/tags/$tag", {
$userId: this.credentials.userId,
$roomId: roomId,
$tag: tagName,
});
return this._http.authedRequestWithPrefix(
callback, "DELETE", path, undefined, undefined, httpApi.PREFIX_V2_ALPHA
);
};
/**
* Set a user's power level.
* @param {string} roomId
@@ -1945,7 +1982,7 @@ function doInitialSync(client, historyLen, includeArchived) {
var privateUserData = data.rooms[i].private_user_data || [];
for (j = 0; j < privateUserData.length; j++) {
var event = _PojoToMatrixEventMapper(client)(privateUserData[j]);
if (event.type === "m.tag") {
if (event.getType() === "m.tag") {
room.addTags(event);
}
// XXX: unhandled private user data event - we should probably