From e1942267c5bd7c53776c25279152107f07318f52 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 16 Aug 2017 14:45:15 +0100 Subject: [PATCH] Add API to invite & remove users from groups (#525) * Add API invite & remove users from groups * lint --- src/base-apis.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index 6e9364b0b..135449835 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -438,6 +438,34 @@ MatrixBaseApis.prototype.getGroupUsers = function(groupId) { return this._http.authedRequest(undefined, "GET", path); }; +/** + * @param {string} groupId + * @param {string} userId + * @return {module:client.Promise} Resolves: Empty object + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.inviteUserToGroup = function(groupId, userId) { + const path = utils.encodeUri( + "/groups/$groupId/admin/users/invite/$userId", + {$groupId: groupId, $userId: userId}, + ); + return this._http.authedRequest(undefined, "PUT", path, undefined, {}); +}; + +/** + * @param {string} groupId + * @param {string} userId + * @return {module:client.Promise} Resolves: Empty object + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.removeUserFromGroup = function(groupId, userId) { + const path = utils.encodeUri( + "/groups/$groupId/admin/users/remove/$userId", + {$groupId: groupId, $userId: userId}, + ); + return this._http.authedRequest(undefined, "PUT", path, undefined, {}); +}; + /** * @return {module:client.Promise} Resolves: The groups to which the user is joined * @return {module:http-api.MatrixError} Rejects: with an error response.