From cd8dfa331a71a8f9809ed7407b48111a8dcc519d Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 13 Feb 2017 18:00:28 +0000 Subject: [PATCH] Fix the unban method Which didn't work because of https://github.com/matrix-org/synapse/issues/1860 --- src/client.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/client.js b/src/client.js index c744ff33d..a0c185a40 100644 --- a/src/client.js +++ b/src/client.js @@ -1380,13 +1380,23 @@ MatrixClient.prototype.forget = function(roomId, deleteRoom, callback) { * @param {string} roomId * @param {string} userId * @param {module:client.callback} callback Optional. - * @return {module:client.Promise} Resolves: TODO + * @return {module:client.Promise} Resolves: Object (currently empty) * @return {module:http-api.MatrixError} Rejects: with an error response. */ MatrixClient.prototype.unban = function(roomId, userId, callback) { - // unbanning = set their state to leave - return _setMembershipState( - this, roomId, userId, "leave", undefined, callback, + // unbanning != set their state to leave: this used to be + // the case, but was then changed so that leaving was always + // a revoking of priviledge, otherwise two people racing to + // kick / ban someone could end up banning and then un-banning + // them. + const path = utils.encodeUri("/rooms/$roomId/unban", { + $roomId: roomId, + }); + const data = { + user_id: userId, + }; + return this._http.authedRequest( + callback, "POST", path, undefined, data, ); };