Skip to content

Commit c696abf

Browse files
committed
Merge tag 'v17.1.0' into sc
* Add MatrixClient.doesServerSupportLogoutDevices() for MSC2457 ([\matrix-org#2297](matrix-org#2297)). * Live location sharing - expose room liveBeaconIds ([\matrix-org#2296](matrix-org#2296)). * Support for MSC2457 logout_devices param for setPassword() ([\matrix-org#2285](matrix-org#2285)). * Stabilise token authenticated registration support ([\matrix-org#2181](matrix-org#2181)). Contributed by @govynnus. * Live location sharing - Aggregate beacon locations on beacons ([\matrix-org#2268](matrix-org#2268)). * Prevent duplicated re-emitter setups in event-mapper ([\matrix-org#2293](matrix-org#2293)). * Make self membership less prone to races ([\matrix-org#2277](matrix-org#2277)). Fixes element-hq/element-web#21661.
2 parents e82be9f + 738876a commit c696abf

28 files changed

+719
-190
lines changed

.git-blame-ignore-revs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Minor white-space adjustments
2+
1d1d59c75744e1f6a2be1cb3e0d1bd9ded5f8025
3+
# Import ordering and spacing: eslint-plugin-import
4+
80aaa6c32b50601f82e0c991c24e5a4590f39463
5+
# Minor white-space adjustment
6+
8fb036ba2d01fab66dc4373802ccf19b5cac8541
7+
# Minor white-space adjustment
8+
b63de6a902a9e1f8ffd7697dea33820fc04f028e
9+
3ca84cfc491b0987eec1f13f13cae58d2032bf54
10+
# Conform to new typescript eslint rules
11+
a87858840b57514603f63e2abbbda4f107f05a77
12+
5cf6684129a921295f5593173f16f192336fe0a2
13+
# Comply with new member-delimiter-style rule
14+
b2ad957d298720d3e026b6bd91be0c403338361a
15+
# Fix semicolons in TS files
16+
e2ec8952e38b8fea3f0ccaa09ecb42feeba0d923
17+
# Migrate to `eslint-plugin-matrix-org`
18+
# and `babel/...` to `@babel/...` migration
19+
09fac77ce0d9bcf6637088c29afab84084f0e739
20+
102704e91a70643bcc09721e14b0d909f0ef55c6
21+
# Eslint formatting
22+
cec00cd303787fa9008b6c48826e75ed438036fa
23+
# Minor eslint changes
24+
68bb8182e4e62d8f450f80c408c4b231b8725f1b
25+
c979ff6696e30ab8983ac416a3590996d84d3560
26+
f4a7395e3a3751a1a8e92dd302c49175a3296ad2
27+
# eslint --fix for dangley commas on function calls
28+
423175f5397910b0afe3112d6fb18283fc7d27d4
29+
# eslint ---fix for prefer-const
30+
7bca05af644e8b997dae81e568a3913d8f18d7ca
31+
# Fix linting on tests
32+
cee7f7a280a8c20bafc21c0a2911f60851f7a7ca
33+
# eslint --fix
34+
0fa9f7c6098822db1ae214f352fd1fe5c248b02c
35+
# eslint --fix for lots of white-space
36+
5abf6b9f208801c5022a47023150b5846cb0b309
37+
# eslint --fix
38+
7ed65407e6cdf292ce3cf659310c68d19dcd52b2
39+
# Switch to ESLint from JSHint (Google eslint rules as a base)
40+
e057956ede9ad1a931ff8050c411aca7907e0394
41+

.github/workflows/test_coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ jobs:
2929
with:
3030
fail_ci_if_error: false
3131
verbose: true
32+
override_commit: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
Changes in [17.1.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v17.1.0) (2022-04-26)
2+
==================================================================================================
3+
4+
## ✨ Features
5+
* Add MatrixClient.doesServerSupportLogoutDevices() for MSC2457 ([\#2297](https://github.com/matrix-org/matrix-js-sdk/pull/2297)).
6+
* Live location sharing - expose room liveBeaconIds ([\#2296](https://github.com/matrix-org/matrix-js-sdk/pull/2296)).
7+
* Support for MSC2457 logout_devices param for setPassword() ([\#2285](https://github.com/matrix-org/matrix-js-sdk/pull/2285)).
8+
* Stabilise token authenticated registration support ([\#2181](https://github.com/matrix-org/matrix-js-sdk/pull/2181)). Contributed by @govynnus.
9+
* Live location sharing - Aggregate beacon locations on beacons ([\#2268](https://github.com/matrix-org/matrix-js-sdk/pull/2268)).
10+
11+
## 🐛 Bug Fixes
12+
* Prevent duplicated re-emitter setups in event-mapper ([\#2293](https://github.com/matrix-org/matrix-js-sdk/pull/2293)).
13+
* Make self membership less prone to races ([\#2277](https://github.com/matrix-org/matrix-js-sdk/pull/2277)). Fixes vector-im/element-web#21661.
14+
115
Changes in [17.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v17.0.0) (2022-04-11)
216
==================================================================================================
317

examples/node/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ function printLine(event) {
341341

342342
var maxNameWidth = 15;
343343
if (name.length > maxNameWidth) {
344-
name = name.substr(0, maxNameWidth-1) + "\u2026";
344+
name = name.slice(0, maxNameWidth-1) + "\u2026";
345345
}
346346

347347
if (event.getType() === "m.room.message") {
@@ -398,7 +398,7 @@ function print(str, formatter) {
398398

399399
function fixWidth(str, len) {
400400
if (str.length > len) {
401-
return str.substr(0, len-2) + "\u2026";
401+
return str.substring(0, len-2) + "\u2026";
402402
}
403403
else if (str.length < len) {
404404
return str + new Array(len - str.length).join(" ");

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "17.0.0",
3+
"version": "17.1.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"scripts": {
66
"prepublishOnly": "yarn build",

spec/integ/matrix-client-event-timeline.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ describe("MatrixClient event timelines", function() {
496496
});
497497

498498
it("should handle thread replies with server support by fetching a contiguous thread timeline", async () => {
499+
client.clientOpts.experimentalThreadSupport = true;
499500
Thread.setServerSideSupport(true);
500501
client.stopClient(); // we don't need the client to be syncing at this time
501502
const room = client.getRoom(roomId);

spec/test-utils/beacon.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const makeBeaconInfoEvent = (
4242
roomId: string,
4343
contentProps: Partial<InfoContentProps> = {},
4444
eventId?: string,
45-
eventTypeSuffix?: string,
4645
): MatrixEvent => {
4746
const {
4847
timeout, isLive, description, assetType,
@@ -51,12 +50,14 @@ export const makeBeaconInfoEvent = (
5150
...contentProps,
5251
};
5352
const event = new MatrixEvent({
54-
type: `${M_BEACON_INFO.name}.${sender}.${eventTypeSuffix || Date.now()}`,
53+
type: M_BEACON_INFO.name,
5554
room_id: roomId,
5655
state_key: sender,
5756
content: makeBeaconInfoContent(timeout, isLive, description, assetType),
5857
});
5958

59+
event.event.origin_server_ts = Date.now();
60+
6061
// live beacons use the beacon_info event id
6162
// set or default this
6263
event.replaceLocalEventId(eventId || `$${Math.random()}-${Math.random()}`);

spec/unit/content-helpers.spec.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ limitations under the License.
1616

1717
import { REFERENCE_RELATION } from "matrix-events-sdk";
1818

19-
import { M_BEACON_INFO } from "../../src/@types/beacon";
2019
import { LocationAssetType, M_ASSET, M_LOCATION, M_TIMESTAMP } from "../../src/@types/location";
2120
import { makeBeaconContent, makeBeaconInfoContent } from "../../src/content-helpers";
2221

@@ -36,11 +35,9 @@ describe('Beacon content helpers', () => {
3635
'nice beacon_info',
3736
LocationAssetType.Pin,
3837
)).toEqual({
39-
[M_BEACON_INFO.name]: {
40-
description: 'nice beacon_info',
41-
timeout: 1234,
42-
live: true,
43-
},
38+
description: 'nice beacon_info',
39+
timeout: 1234,
40+
live: true,
4441
[M_TIMESTAMP.name]: mockDateNow,
4542
[M_ASSET.name]: {
4643
type: LocationAssetType.Pin,

spec/unit/matrix-client.spec.ts

Lines changed: 90 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import * as testUtils from "../test-utils/test-utils";
3333
import { makeBeaconInfoContent } from "../../src/content-helpers";
3434
import { M_BEACON_INFO } from "../../src/@types/beacon";
3535
import { Room } from "../../src";
36+
import { makeBeaconEvent } from "../test-utils/beacon";
3637

3738
jest.useFakeTimers();
3839

@@ -815,6 +816,9 @@ describe("MatrixClient", function() {
815816
},
816817
addPendingEvent: jest.fn(),
817818
updatePendingEvent: jest.fn(),
819+
reEmitter: {
820+
reEmit: jest.fn(),
821+
},
818822
};
819823

820824
beforeEach(() => {
@@ -999,10 +1003,10 @@ describe("MatrixClient", function() {
9991003
});
10001004

10011005
it("creates new beacon info", async () => {
1002-
await client.unstable_createLiveBeacon(roomId, content, '123');
1006+
await client.unstable_createLiveBeacon(roomId, content);
10031007

10041008
// event type combined
1005-
const expectedEventType = `${M_BEACON_INFO.name}.${userId}.123`;
1009+
const expectedEventType = M_BEACON_INFO.name;
10061010
const [callback, method, path, queryParams, requestContent] = client.http.authedRequest.mock.calls[0];
10071011
expect(callback).toBeFalsy();
10081012
expect(method).toBe('PUT');
@@ -1015,17 +1019,97 @@ describe("MatrixClient", function() {
10151019
});
10161020

10171021
it("updates beacon info with specific event type", async () => {
1018-
const eventType = `${M_BEACON_INFO.name}.${userId}.456`;
1019-
1020-
await client.unstable_setLiveBeacon(roomId, eventType, content);
1022+
await client.unstable_setLiveBeacon(roomId, content);
10211023

10221024
// event type combined
10231025
const [, , path, , requestContent] = client.http.authedRequest.mock.calls[0];
10241026
expect(path).toEqual(
10251027
`/rooms/${encodeURIComponent(roomId)}/state/` +
1026-
`${encodeURIComponent(eventType)}/${encodeURIComponent(userId)}`,
1028+
`${encodeURIComponent(M_BEACON_INFO.name)}/${encodeURIComponent(userId)}`,
10271029
);
10281030
expect(requestContent).toEqual(content);
10291031
});
1032+
1033+
describe('processBeaconEvents()', () => {
1034+
it('does nothing when events is falsy', () => {
1035+
const room = new Room(roomId, client, userId);
1036+
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
1037+
1038+
client.processBeaconEvents(room, undefined);
1039+
expect(roomStateProcessSpy).not.toHaveBeenCalled();
1040+
});
1041+
1042+
it('does nothing when events is of length 0', () => {
1043+
const room = new Room(roomId, client, userId);
1044+
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
1045+
1046+
client.processBeaconEvents(room, []);
1047+
expect(roomStateProcessSpy).not.toHaveBeenCalled();
1048+
});
1049+
1050+
it('calls room states processBeaconEvents with m.beacon events', () => {
1051+
const room = new Room(roomId, client, userId);
1052+
const roomStateProcessSpy = jest.spyOn(room.currentState, 'processBeaconEvents');
1053+
1054+
const messageEvent = testUtils.mkMessage({ room: roomId, user: userId, event: true });
1055+
const beaconEvent = makeBeaconEvent(userId);
1056+
1057+
client.processBeaconEvents(room, [messageEvent, beaconEvent]);
1058+
expect(roomStateProcessSpy).toHaveBeenCalledWith([beaconEvent]);
1059+
});
1060+
});
1061+
});
1062+
1063+
describe("setPassword", () => {
1064+
const auth = { session: 'abcdef', type: 'foo' };
1065+
const newPassword = 'newpassword';
1066+
const callback = () => {};
1067+
1068+
const passwordTest = (expectedRequestContent: any, expectedCallback?: Function) => {
1069+
const [callback, method, path, queryParams, requestContent] = client.http.authedRequest.mock.calls[0];
1070+
if (expectedCallback) {
1071+
expect(callback).toBe(expectedCallback);
1072+
} else {
1073+
expect(callback).toBeFalsy();
1074+
}
1075+
expect(method).toBe('POST');
1076+
expect(path).toEqual('/account/password');
1077+
expect(queryParams).toBeFalsy();
1078+
expect(requestContent).toEqual(expectedRequestContent);
1079+
};
1080+
1081+
beforeEach(() => {
1082+
client.http.authedRequest.mockClear().mockResolvedValue({});
1083+
});
1084+
1085+
it("no logout_devices specified", async () => {
1086+
await client.setPassword(auth, newPassword);
1087+
passwordTest({ auth, new_password: newPassword });
1088+
});
1089+
1090+
it("no logout_devices specified + callback", async () => {
1091+
await client.setPassword(auth, newPassword, callback);
1092+
passwordTest({ auth, new_password: newPassword }, callback);
1093+
});
1094+
1095+
it("overload logoutDevices=true", async () => {
1096+
await client.setPassword(auth, newPassword, true);
1097+
passwordTest({ auth, new_password: newPassword, logout_devices: true });
1098+
});
1099+
1100+
it("overload logoutDevices=true + callback", async () => {
1101+
await client.setPassword(auth, newPassword, true, callback);
1102+
passwordTest({ auth, new_password: newPassword, logout_devices: true }, callback);
1103+
});
1104+
1105+
it("overload logoutDevices=false", async () => {
1106+
await client.setPassword(auth, newPassword, false);
1107+
passwordTest({ auth, new_password: newPassword, logout_devices: false });
1108+
});
1109+
1110+
it("overload logoutDevices=false + callback", async () => {
1111+
await client.setPassword(auth, newPassword, false, callback);
1112+
passwordTest({ auth, new_password: newPassword, logout_devices: false }, callback);
1113+
});
10301114
});
10311115
});

0 commit comments

Comments
 (0)