From d53cd41aa624e2b8472b89ef12c0d4cc43692e47 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 29 Mar 2018 12:42:16 +0100 Subject: [PATCH] Add wrapper for group join API (#633) Needed for new "joinable" groups. --- src/base-apis.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/base-apis.js b/src/base-apis.js index 7f395361a..1d59d9137 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -633,6 +633,19 @@ MatrixBaseApis.prototype.acceptGroupInvite = function(groupId, opts = null) { return this._http.authedRequest(undefined, "PUT", path, undefined, opts || {}); }; +/** + * @param {string} groupId + * @return {module:client.Promise} Resolves: Empty object + * @return {module:http-api.MatrixError} Rejects: with an error response. + */ +MatrixBaseApis.prototype.joinGroup = function(groupId) { + const path = utils.encodeUri( + "/groups/$groupId/self/join", + {$groupId: groupId}, + ); + return this._http.authedRequest(undefined, "PUT", path, undefined, {}); +}; + /** * @param {string} groupId * @return {module:client.Promise} Resolves: Empty object