Skip to content

Commit

Permalink
Merge pull request #326 from matrix-org/hs/bot-sdk
Browse files Browse the repository at this point in the history
Use the matrix-bot-sdk for Matrix API calls
  • Loading branch information
Half-Shot authored Aug 16, 2021
2 parents 4a80d46 + 263bfe7 commit e1991f1
Show file tree
Hide file tree
Showing 16 changed files with 1,093 additions and 763 deletions.
2 changes: 2 additions & 0 deletions changelog.d/326.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
**Breaking**: This library now uses the [matrix-bot-sdk](https://github.com/turt2live/matrix-bot-sdk) for Matrix requests. Previously, the bridge used the matrix-js-sdk which
is now deprecated in this release, but can still be accessed via `Intent.getClient()`.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"extend": "^3.0.2",
"is-my-json-valid": "^2.20.5",
"js-yaml": "^4.0.0",
"matrix-bot-sdk": "^0.5.19",
"matrix-appservice": "^0.8.0",
"matrix-js-sdk": "^9.9.0",
"nedb": "^1.8.0",
Expand Down
392 changes: 170 additions & 222 deletions spec/integ/bridge.spec.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/unit/app-service-bot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("AppServiceBot", function() {
}]
}
});
bot = new AppServiceBot(client, reg);
bot = new AppServiceBot(client, botUserId, reg);
});

describe("getMemberLists", function() {
Expand Down
303 changes: 145 additions & 158 deletions spec/unit/intent.spec.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions spec/unit/room-upgrade-handler.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("RoomUpgradeHandler", () => {
let joined;
const bridge = {
getIntent: () => ({
join: (roomId) => { joined = roomId; return Promise.reject({errcode: "M_FORBIDDEN"}); },
join: (roomId) => { joined = roomId; return Promise.reject({body: {errcode: "M_FORBIDDEN"}}); },
}),
};
const ruh = new RoomUpgradeHandler({}, bridge);
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("RoomUpgradeHandler", () => {
let joined;
const bridge = {
getIntent: () => ({
join: (roomId) => { joined = roomId; return Promise.reject({errcode: "M_FORBIDDEN"}); },
join: (roomId) => { joined = roomId; return Promise.reject({body: {errcode: "M_FORBIDDEN"}}); },
}),
};
const ruh = new RoomUpgradeHandler({}, bridge);
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/state-lookup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@ describe("StateLookup", function() {
it("should fail the promise if the HTTP call returns 4xx", function(done) {
cli.roomState.and.callFake(function(roomId) {
return Promise.reject({
httpStatus: 403
statusCode: 403
});
});

lookup.trackRoom("!foo:bar").catch(function(err) {
expect(err.httpStatus).toBe(403);
expect(err.statusCode).toBe(403);
done();
});
});

it("should fail the promise if the HTTP call returns 5xx", function(done) {
cli.roomState.and.callFake(function(roomId) {
return Promise.reject({
httpStatus: 500
statusCode: 500
});
});

lookup.trackRoom("!foo:bar").catch(function(err) {
expect(err.httpStatus).toBe(500);
expect(err.statusCode).toBe(500);
done();
});
});
Expand Down
Loading

0 comments on commit e1991f1

Please sign in to comment.