diff --git a/src/client.js b/src/client.js index be4e5857b..1956b9225 100644 --- a/src/client.js +++ b/src/client.js @@ -921,6 +921,8 @@ MatrixClient.prototype.isUserIgnored = function(userId) { * Default: true. * @param {boolean} opts.inviteSignUrl If the caller has a keypair 3pid invite, * the signing URL is passed in this parameter. + * @param {string[]} opts.viaServers The server names to try and join through in + * addition to those that are automatically chosen. * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: Room object. * @return {module:http-api.MatrixError} Rejects: with an error response. @@ -949,6 +951,13 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) { ); } + const queryString = {}; + if (opts.viaServers) { + queryString["server_name"] = opts.viaServers; + } + + const reqOpts = {qsStringifyOptions: {arrayFormat: 'repeat'}}; + const defer = Promise.defer(); const self = this; @@ -959,7 +968,7 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) { } const path = utils.encodeUri("/join/$roomid", { $roomid: roomIdOrAlias}); - return self._http.authedRequest(undefined, "POST", path, undefined, data); + return self._http.authedRequest(undefined, "POST", path, queryString, data, reqOpts); }).then(function(res) { const roomId = res.room_id; const syncApi = new SyncApi(self, self._clientOpts); diff --git a/src/http-api.js b/src/http-api.js index b753d6bf8..ca71d5668 100644 --- a/src/http-api.js +++ b/src/http-api.js @@ -668,6 +668,9 @@ module.exports.MatrixHttpApi.prototype = { * @param {function=} opts.bodyParser function to parse the body of the * response before passing it to the promise and callback. * + * @param (object=} opts.qsStringifyOptions options for stringifying the + * query string. + * * @return {module:client.Promise} a promise which resolves to either the * response object (if this.opts.onlyData is truthy), or the parsed * body. Rejects @@ -752,6 +755,8 @@ module.exports.MatrixHttpApi.prototype = { method: method, withCredentials: false, qs: queryParams, + //qsStringifyOptions: opts.qsStringifyOptions, + useQuerystring: true, body: data, json: false, timeout: localTimeoutMs,