Skip to content

Commit 01e31af

Browse files
authored
Merge pull request #764 from matrix-org/travis/permalink-routing
Support `request` in the browser and support supplying servers to try in joinRoom()
2 parents e69f7db + 64b83b3 commit 01e31af

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

browser-index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var matrixcs = require("./lib/matrix");
2-
matrixcs.request(require("browser-request"));
2+
matrixcs.request(require("request"));
33

44
// just *accessing* indexedDB throws an exception in firefox with
55
// indexeddb disabled.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,16 @@
5858
"browser-request": "^0.3.3",
5959
"content-type": "^1.0.2",
6060
"loglevel": "1.6.1",
61-
"request": "^2.53.0"
61+
"memfs": "^2.10.1",
62+
"request": "^2.88.0"
6263
},
6364
"devDependencies": {
6465
"babel-cli": "^6.18.0",
6566
"babel-eslint": "^7.1.1",
6667
"babel-plugin-transform-async-to-bluebird": "^1.1.1",
6768
"babel-plugin-transform-runtime": "^6.23.0",
6869
"babel-preset-es2015": "^6.18.0",
69-
"browserify": "^14.0.0",
70+
"browserify": "^16.2.3",
7071
"browserify-shim": "^3.8.13",
7172
"eslint": "^3.13.1",
7273
"eslint-config-google": "^0.7.1",
@@ -82,7 +83,7 @@
8283
"source-map-support": "^0.4.11",
8384
"sourceify": "^0.1.0",
8485
"uglify-js": "^2.8.26",
85-
"watchify": "^3.2.1"
86+
"watchify": "^3.11.0"
8687
},
8788
"browserify": {
8889
"transform": [

src/client.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,8 @@ MatrixClient.prototype.isUserIgnored = function(userId) {
918918
* </strong> Default: true.
919919
* @param {boolean} opts.inviteSignUrl If the caller has a keypair 3pid invite,
920920
* the signing URL is passed in this parameter.
921+
* @param {string[]} opts.viaServers The server names to try and join through in
922+
* addition to those that are automatically chosen.
921923
* @param {module:client.callback} callback Optional.
922924
* @return {module:client.Promise} Resolves: Room object.
923925
* @return {module:http-api.MatrixError} Rejects: with an error response.
@@ -946,6 +948,13 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
946948
);
947949
}
948950

951+
const queryString = {};
952+
if (opts.viaServers) {
953+
queryString["server_name"] = opts.viaServers;
954+
}
955+
956+
const reqOpts = {qsStringifyOptions: {arrayFormat: 'repeat'}};
957+
949958
const defer = Promise.defer();
950959

951960
const self = this;
@@ -956,7 +965,8 @@ MatrixClient.prototype.joinRoom = function(roomIdOrAlias, opts, callback) {
956965
}
957966

958967
const path = utils.encodeUri("/join/$roomid", { $roomid: roomIdOrAlias});
959-
return self._http.authedRequest(undefined, "POST", path, undefined, data);
968+
return self._http.authedRequest(
969+
undefined, "POST", path, queryString, data, reqOpts);
960970
}).then(function(res) {
961971
const roomId = res.room_id;
962972
const syncApi = new SyncApi(self, self._clientOpts);

src/http-api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ module.exports.MatrixHttpApi.prototype = {
752752
method: method,
753753
withCredentials: false,
754754
qs: queryParams,
755+
qsStringifyOptions: opts.qsStringifyOptions,
756+
useQuerystring: true,
755757
body: data,
756758
json: false,
757759
timeout: localTimeoutMs,

0 commit comments

Comments
 (0)