mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 11:54:56 -04:00
Merge branch 'develop' of github.com:matrix-org/synapse into develop
Conflicts: synapse/http/client.py
This commit is contained in:
commit
d72ce4da64
168 changed files with 1898 additions and 789 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2014 matrix.org
|
||||
Copyright 2014 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -167,6 +167,29 @@ angular.module('matrixService', [])
|
|||
return doRequest("POST", path, undefined, data);
|
||||
},
|
||||
|
||||
// Change the membership of an another user
|
||||
setMembership: function(room_id, user_id, membershipValue) {
|
||||
// The REST path spec
|
||||
var path = "/rooms/$room_id/state/m.room.member/$user_id";
|
||||
path = path.replace("$room_id", encodeURIComponent(room_id));
|
||||
path = path.replace("$user_id", user_id);
|
||||
|
||||
return doRequest("PUT", path, undefined, {
|
||||
membership: membershipValue
|
||||
});
|
||||
},
|
||||
|
||||
// Bans a user from from a room
|
||||
ban: function(room_id, user_id, reason) {
|
||||
var path = "/rooms/$room_id/ban";
|
||||
path = path.replace("$room_id", encodeURIComponent(room_id));
|
||||
|
||||
return doRequest("POST", path, undefined, {
|
||||
user_id: user_id,
|
||||
reason: reason
|
||||
});
|
||||
},
|
||||
|
||||
// Retrieves the room ID corresponding to a room alias
|
||||
resolveRoomAlias:function(room_alias) {
|
||||
var path = "/_matrix/client/api/v1/directory/room/$room_alias";
|
||||
|
@ -253,7 +276,7 @@ angular.module('matrixService', [])
|
|||
|
||||
// get a list of public rooms on your home server
|
||||
publicRooms: function() {
|
||||
var path = "/publicRooms"
|
||||
var path = "/publicRooms";
|
||||
return doRequest("GET", path);
|
||||
},
|
||||
|
||||
|
@ -309,7 +332,7 @@ angular.module('matrixService', [])
|
|||
|
||||
// hit the Identity Server for a 3PID request.
|
||||
linkEmail: function(email, clientSecret, sendAttempt) {
|
||||
var path = "/_matrix/identity/api/v1/validate/email/requestToken"
|
||||
var path = "/_matrix/identity/api/v1/validate/email/requestToken";
|
||||
var data = "clientSecret="+clientSecret+"&email=" + encodeURIComponent(email)+"&sendAttempt="+sendAttempt;
|
||||
var headers = {};
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
||||
|
@ -414,7 +437,8 @@ angular.module('matrixService', [])
|
|||
state: presence
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
/****** Permanent storage of user information ******/
|
||||
|
||||
// Returns the current config
|
||||
|
@ -514,6 +538,35 @@ angular.module('matrixService', [])
|
|||
}
|
||||
}
|
||||
return powerLevel;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change or reset the power level of a user
|
||||
* @param {String} room_id the room id
|
||||
* @param {String} user_id the user id
|
||||
* @param {Number} powerLevel a value between 0 and 10
|
||||
* If undefined, the user power level will be reset, ie he will use the default room user power level
|
||||
* @returns {promise} an $http promise
|
||||
*/
|
||||
setUserPowerLevel: function(room_id, user_id, powerLevel) {
|
||||
|
||||
// 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);
|
||||
content[user_id] = powerLevel;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue