You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Initial support for specifying which servers to try in joinRoom
This has a bug when using browser-request where the query string for `server_name: [a, b]` comes out as `?server_name=a,b` instead of `?server_name=a&server_name=b`. This is due to browser-request not supporting the same qs options as request, so the qsStringifyOptions do nothing.
This commit is contained in:
@@ -921,6 +921,8 @@ MatrixClient.prototype.isUserIgnored = function(userId) {
|
|||||||
* </strong> Default: true.
|
* </strong> Default: true.
|
||||||
* @param {boolean} opts.inviteSignUrl If the caller has a keypair 3pid invite,
|
* @param {boolean} opts.inviteSignUrl If the caller has a keypair 3pid invite,
|
||||||
* the signing URL is passed in this parameter.
|
* 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.
|
* @param {module:client.callback} callback Optional.
|
||||||
* @return {module:client.Promise} Resolves: Room object.
|
* @return {module:client.Promise} Resolves: Room object.
|
||||||
* @return {module:http-api.MatrixError} Rejects: with an error response.
|
* @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 defer = Promise.defer();
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
@@ -959,7 +968,7 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const path = utils.encodeUri("/join/$roomid", { $roomid: roomIdOrAlias});
|
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) {
|
}).then(function(res) {
|
||||||
const roomId = res.room_id;
|
const roomId = res.room_id;
|
||||||
const syncApi = new SyncApi(self, self._clientOpts);
|
const syncApi = new SyncApi(self, self._clientOpts);
|
||||||
|
|||||||
@@ -668,6 +668,9 @@ module.exports.MatrixHttpApi.prototype = {
|
|||||||
* @param {function=} opts.bodyParser function to parse the body of the
|
* @param {function=} opts.bodyParser function to parse the body of the
|
||||||
* response before passing it to the promise and callback.
|
* 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
|
* @return {module:client.Promise} a promise which resolves to either the
|
||||||
* response object (if this.opts.onlyData is truthy), or the parsed
|
* response object (if this.opts.onlyData is truthy), or the parsed
|
||||||
* body. Rejects
|
* body. Rejects
|
||||||
@@ -752,6 +755,8 @@ module.exports.MatrixHttpApi.prototype = {
|
|||||||
method: method,
|
method: method,
|
||||||
withCredentials: false,
|
withCredentials: false,
|
||||||
qs: queryParams,
|
qs: queryParams,
|
||||||
|
//qsStringifyOptions: opts.qsStringifyOptions,
|
||||||
|
useQuerystring: true,
|
||||||
body: data,
|
body: data,
|
||||||
json: false,
|
json: false,
|
||||||
timeout: localTimeoutMs,
|
timeout: localTimeoutMs,
|
||||||
|
|||||||
Reference in New Issue
Block a user