mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-29 23:06:11 -05:00
Added /deop $user_id
This commit is contained in:
parent
756e171ad0
commit
932f35a7f0
@ -522,7 +522,6 @@ angular.module('matrixService', [])
|
|||||||
return powerLevel;
|
return powerLevel;
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
* Change the power level of a user
|
* Change the power level of a user
|
||||||
* @param {String} room_id the room id
|
* @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
|
// The room does not exist or does not contain power_levels data
|
||||||
var deferred = $q.defer();
|
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;
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,13 +299,21 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "/op":
|
case "/op":
|
||||||
|
// Define the power level of an user
|
||||||
if (3 === args.length) {
|
if (3 === args.length) {
|
||||||
var user_id = args[1];
|
var user_id = args[1];
|
||||||
var powerLevel = parseInt(args[2]);
|
var powerLevel = parseInt(args[2]);
|
||||||
|
|
||||||
promise = matrixService.setUserPowerLevel($scope.room_id, user_id, powerLevel);
|
promise = matrixService.setUserPowerLevel($scope.room_id, user_id, powerLevel);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "/deop":
|
||||||
|
// Reset the power level of an user
|
||||||
|
if (2 === args.length) {
|
||||||
|
var user_id = args[1];
|
||||||
|
promise = matrixService.resetUserPowerLevel($scope.room_id, user_id);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user