diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-03 15:14:13 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-03 15:20:09 +0200 |
commit | 932f35a7f0bb37c6f2279634f74dc6eb8d81b3af (patch) | |
tree | d5e861b7b3052f47a214561457c1b53c45fa732a /webclient/components | |
parent | Store SQL DDL deltas as well; attempt to upgrade the database on startup if i... (diff) | |
download | synapse-932f35a7f0bb37c6f2279634f74dc6eb8d81b3af.tar.xz |
Added /deop $user_id
Diffstat (limited to 'webclient/components')
-rw-r--r-- | webclient/components/matrix/matrix-service.js | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index bedabe6286..eadbb03d9e 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -522,7 +522,6 @@ angular.module('matrixService', []) return powerLevel; }, - // /** * Change the power level of a user * @param {String} room_id the room id @@ -554,7 +553,33 @@ angular.module('matrixService', []) // The room does not exist or does not contain power_levels data var deferred = $q.defer(); - deferred.reject({data:{error: "Invalied room: " + room_id}}); + deferred.reject({data:{error: "Invalid room: " + room_id}}); + return deferred.promise; + }, + + /** + * reset the power level of a user so that he will use the room default power level + * @param {String} room_id the room id + * @param {String} user_id the user id + * @returns {promise} an $http promise + */ + resetUserPowerLevel: function(room_id, user_id) { + // Hack: currently, there is no home server API so do it by hand by updating + // the current m.room.power_levels of the room and send it to the server + var room = $rootScope.events.rooms[room_id]; + if (room && room["m.room.power_levels"]) { + var content = angular.copy(room["m.room.power_levels"].content); + delete content[user_id]; + + var path = "/rooms/$room_id/state/m.room.power_levels"; + path = path.replace("$room_id", encodeURIComponent(room_id)); + + return doRequest("PUT", path, undefined, content); + } + + // The room does not exist or does not contain power_levels data + var deferred = $q.defer(); + deferred.reject({data:{error: "Invalid room: " + room_id}}); return deferred.promise; } |