Skip to content

Commit 8daa03b

Browse files
committed
Merge tag 'v16.0.0' into sc
* Improve typing around event emitter handlers ([\matrix-org#2180](matrix-org#2180)). * Fix defer not supporting resolving with a Promise<T> ([\matrix-org#2216](matrix-org#2216)). * add LocationAssetType enum ([\matrix-org#2214](matrix-org#2214)). * Support for mid-call devices changes ([\matrix-org#2154](matrix-org#2154)). Contributed by @SimonBrandner. * Add new room state emit RoomStateEvent.Update for lower-frequency hits ([\matrix-org#2192](matrix-org#2192)). * Fix wrong event_id being sent for m.in_reply_to of threads ([\matrix-org#2213](matrix-org#2213)). * Fix wrongly asserting that PushRule::conditions is non-null ([\matrix-org#2217](matrix-org#2217)). * Make createThread more resilient when missing rootEvent ([\matrix-org#2207](matrix-org#2207)). Fixes element-hq/element-web#21130. * Fix bug with the /hierarchy API sending invalid requests ([\matrix-org#2201](matrix-org#2201)). Fixes element-hq/element-web#21170. * fix relation sender filter ([\matrix-org#2196](matrix-org#2196)). Fixes element-hq/element-web#20877. * Fix bug with one-way audio after a transfer ([\matrix-org#2193](matrix-org#2193)).
2 parents 8502dd1 + f1db4dc commit 8daa03b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2333
-1308
lines changed

.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ module.exports = {
3131
"no-async-promise-executor": "off",
3232
// We use a `logger` intermediary module
3333
"no-console": "error",
34+
35+
// restrict EventEmitters to force callers to use TypedEventEmitter
36+
"no-restricted-imports": ["error", "events"],
3437
},
3538
overrides: [{
3639
files: [

.github/codecov.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
comment:
2+
layout: "diff, files"
3+
behavior: default
4+
require_changes: false
5+
require_base: no
6+
require_head: no

.github/workflows/test_coverage.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Test coverage
2+
on:
3+
pull_request: {}
4+
push:
5+
branches: [develop, main, master]
6+
jobs:
7+
test-coverage:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Run tests with coverage
14+
run: "yarn install && yarn build && yarn coverage"
15+
16+
- name: Upload coverage
17+
uses: codecov/codecov-action@v2
18+
with:
19+
verbose: true

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
Changes in [16.0.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v16.0.0) (2022-03-15)
2+
==================================================================================================
3+
4+
## 🚨 BREAKING CHANGES
5+
* Improve typing around event emitter handlers ([\#2180](https://github.com/matrix-org/matrix-js-sdk/pull/2180)).
6+
7+
## ✨ Features
8+
* Fix defer not supporting resolving with a Promise<T> ([\#2216](https://github.com/matrix-org/matrix-js-sdk/pull/2216)).
9+
* add LocationAssetType enum ([\#2214](https://github.com/matrix-org/matrix-js-sdk/pull/2214)).
10+
* Support for mid-call devices changes ([\#2154](https://github.com/matrix-org/matrix-js-sdk/pull/2154)). Contributed by @SimonBrandner.
11+
* Add new room state emit RoomStateEvent.Update for lower-frequency hits ([\#2192](https://github.com/matrix-org/matrix-js-sdk/pull/2192)).
12+
13+
## 🐛 Bug Fixes
14+
* Fix wrong event_id being sent for m.in_reply_to of threads ([\#2213](https://github.com/matrix-org/matrix-js-sdk/pull/2213)).
15+
* Fix wrongly asserting that PushRule::conditions is non-null ([\#2217](https://github.com/matrix-org/matrix-js-sdk/pull/2217)).
16+
* Make createThread more resilient when missing rootEvent ([\#2207](https://github.com/matrix-org/matrix-js-sdk/pull/2207)). Fixes vector-im/element-web#21130.
17+
* Fix bug with the /hierarchy API sending invalid requests ([\#2201](https://github.com/matrix-org/matrix-js-sdk/pull/2201)). Fixes vector-im/element-web#21170.
18+
* fix relation sender filter ([\#2196](https://github.com/matrix-org/matrix-js-sdk/pull/2196)). Fixes vector-im/element-web#20877.
19+
* Fix bug with one-way audio after a transfer ([\#2193](https://github.com/matrix-org/matrix-js-sdk/pull/2193)).
20+
21+
Changes in [16.0.0-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v16.0.0-rc.1) (2022-03-08)
22+
============================================================================================================
23+
24+
## 🚨 BREAKING CHANGES
25+
* Improve typing around event emitter handlers ([\#2180](https://github.com/matrix-org/matrix-js-sdk/pull/2180)).
26+
27+
## ✨ Features
28+
* Fix defer not supporting resolving with a Promise<T> ([\#2216](https://github.com/matrix-org/matrix-js-sdk/pull/2216)).
29+
* add LocationAssetType enum ([\#2214](https://github.com/matrix-org/matrix-js-sdk/pull/2214)).
30+
* Support for mid-call devices changes ([\#2154](https://github.com/matrix-org/matrix-js-sdk/pull/2154)). Contributed by @SimonBrandner.
31+
* Add new room state emit RoomStateEvent.Update for lower-frequency hits ([\#2192](https://github.com/matrix-org/matrix-js-sdk/pull/2192)).
32+
33+
## 🐛 Bug Fixes
34+
* Fix wrong event_id being sent for m.in_reply_to of threads ([\#2213](https://github.com/matrix-org/matrix-js-sdk/pull/2213)).
35+
* Fix wrongly asserting that PushRule::conditions is non-null ([\#2217](https://github.com/matrix-org/matrix-js-sdk/pull/2217)).
36+
* Make createThread more resilient when missing rootEvent ([\#2207](https://github.com/matrix-org/matrix-js-sdk/pull/2207)). Fixes vector-im/element-web#21130.
37+
* Fix bug with the /hierarchy API sending invalid requests ([\#2201](https://github.com/matrix-org/matrix-js-sdk/pull/2201)). Fixes vector-im/element-web#21170.
38+
* fix relation sender filter ([\#2196](https://github.com/matrix-org/matrix-js-sdk/pull/2196)). Fixes vector-im/element-web#20877.
39+
* Fix bug with one-way audio after a transfer ([\#2193](https://github.com/matrix-org/matrix-js-sdk/pull/2193)).
40+
141
Changes in [15.6.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.6.0) (2022-02-28)
242
==================================================================================================
343

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "15.6.0",
3+
"version": "16.0.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"scripts": {
66
"prepublishOnly": "yarn build",
@@ -89,7 +89,7 @@
8989
"better-docs": "^2.4.0-beta.9",
9090
"browserify": "^17.0.0",
9191
"docdash": "^1.2.0",
92-
"eslint": "7.18.0",
92+
"eslint": "8.9.0",
9393
"eslint-config-google": "^0.14.0",
9494
"eslint-plugin-import": "^2.25.4",
9595
"eslint-plugin-matrix-org": "^0.4.0",
@@ -113,7 +113,8 @@
113113
"<rootDir>/src/**/*.{js,ts}"
114114
],
115115
"coverageReporters": [
116-
"text"
116+
"text",
117+
"json"
117118
]
118119
},
119120
"typings": "./lib/index.d.ts"

spec/integ/matrix-client-retrying.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventStatus } from "../../src/matrix";
1+
import { EventStatus, RoomEvent } from "../../src/matrix";
22
import { MatrixScheduler } from "../../src/scheduler";
33
import { Room } from "../../src/models/room";
44
import { TestClient } from "../TestClient";
@@ -95,7 +95,7 @@ describe("MatrixClient retrying", function() {
9595

9696
// wait for the localecho of ev1 to be updated
9797
const p3 = new Promise<void>((resolve, reject) => {
98-
room.on("Room.localEchoUpdated", (ev0) => {
98+
room.on(RoomEvent.LocalEchoUpdated, (ev0) => {
9999
if (ev0 === ev1) {
100100
resolve();
101101
}

spec/test-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export function mkEvent(opts) {
8585
room_id: opts.room,
8686
sender: opts.sender || opts.user, // opts.user for backwards-compat
8787
content: opts.content,
88+
unsigned: opts.unsigned,
8889
event_id: "$" + Math.random() + "-" + Math.random(),
8990
};
9091
if (opts.skey !== undefined) {

spec/unit/ReEmitter.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
// eslint-disable-next-line no-restricted-imports
1718
import { EventEmitter } from "events";
1819

1920
import { ReEmitter } from "../../src/ReEmitter";

spec/unit/crypto.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import '../olm-loader';
2+
// eslint-disable-next-line no-restricted-imports
23
import { EventEmitter } from "events";
34

45
import { Crypto } from "../../src/crypto";

spec/unit/crypto/crypto-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function resetCrossSigningKeys(client, {
2626
crypto.crossSigningInfo.keys = oldKeys;
2727
throw e;
2828
}
29-
crypto.baseApis.emit("crossSigning.keysChanged", {});
29+
crypto.emit("crossSigning.keysChanged", {});
3030
await crypto.afterCrossSigningLocalKeyChange();
3131
}
3232

spec/unit/crypto/verification/secret_request.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { VerificationBase } from '../../../../src/crypto/verification/Base';
1817
import { CrossSigningInfo } from '../../../../src/crypto/CrossSigning';
1918
import { encodeBase64 } from "../../../../src/crypto/olmlib";
2019
import { setupWebcrypto, teardownWebcrypto } from './util';
20+
import { VerificationBase } from '../../../../src/crypto/verification/Base';
2121

2222
jest.useFakeTimers();
2323

spec/unit/filter-component.spec.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

spec/unit/filter-component.spec.ts

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import {
2+
RelationType,
3+
UNSTABLE_FILTER_RELATED_BY_REL_TYPES,
4+
UNSTABLE_FILTER_RELATED_BY_SENDERS,
5+
} from "../../src";
6+
import { FilterComponent } from "../../src/filter-component";
7+
import { mkEvent } from '../test-utils';
8+
9+
describe("Filter Component", function() {
10+
describe("types", function() {
11+
it("should filter out events with other types", function() {
12+
const filter = new FilterComponent({ types: ['m.room.message'] });
13+
const event = mkEvent({
14+
type: 'm.room.member',
15+
content: { },
16+
room: 'roomId',
17+
event: true,
18+
});
19+
20+
const checkResult = filter.check(event);
21+
22+
expect(checkResult).toBe(false);
23+
});
24+
25+
it("should validate events with the same type", function() {
26+
const filter = new FilterComponent({ types: ['m.room.message'] });
27+
const event = mkEvent({
28+
type: 'm.room.message',
29+
content: { },
30+
room: 'roomId',
31+
event: true,
32+
});
33+
34+
const checkResult = filter.check(event);
35+
36+
expect(checkResult).toBe(true);
37+
});
38+
39+
it("should filter out events by relation participation", function() {
40+
const currentUserId = '@me:server.org';
41+
const filter = new FilterComponent({
42+
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: [currentUserId],
43+
}, currentUserId);
44+
45+
const threadRootNotParticipated = mkEvent({
46+
type: 'm.room.message',
47+
content: {},
48+
room: 'roomId',
49+
user: '@someone-else:server.org',
50+
event: true,
51+
unsigned: {
52+
"m.relations": {
53+
[RelationType.Thread]: {
54+
count: 2,
55+
current_user_participated: false,
56+
},
57+
},
58+
},
59+
});
60+
61+
expect(filter.check(threadRootNotParticipated)).toBe(false);
62+
});
63+
64+
it("should keep events by relation participation", function() {
65+
const currentUserId = '@me:server.org';
66+
const filter = new FilterComponent({
67+
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: [currentUserId],
68+
}, currentUserId);
69+
70+
const threadRootParticipated = mkEvent({
71+
type: 'm.room.message',
72+
content: {},
73+
unsigned: {
74+
"m.relations": {
75+
[RelationType.Thread]: {
76+
count: 2,
77+
current_user_participated: true,
78+
},
79+
},
80+
},
81+
user: '@someone-else:server.org',
82+
room: 'roomId',
83+
event: true,
84+
});
85+
86+
expect(filter.check(threadRootParticipated)).toBe(true);
87+
});
88+
89+
it("should filter out events by relation type", function() {
90+
const filter = new FilterComponent({
91+
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread],
92+
});
93+
94+
const referenceRelationEvent = mkEvent({
95+
type: 'm.room.message',
96+
content: {},
97+
room: 'roomId',
98+
event: true,
99+
unsigned: {
100+
"m.relations": {
101+
[RelationType.Reference]: {},
102+
},
103+
},
104+
});
105+
106+
expect(filter.check(referenceRelationEvent)).toBe(false);
107+
});
108+
109+
it("should keep events by relation type", function() {
110+
const filter = new FilterComponent({
111+
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread],
112+
});
113+
114+
const threadRootEvent = mkEvent({
115+
type: 'm.room.message',
116+
content: {},
117+
unsigned: {
118+
"m.relations": {
119+
[RelationType.Thread]: {
120+
count: 2,
121+
current_user_participated: true,
122+
},
123+
},
124+
},
125+
room: 'roomId',
126+
event: true,
127+
});
128+
129+
expect(filter.check(threadRootEvent)).toBe(true);
130+
});
131+
});
132+
});

spec/unit/location.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
import { makeLocationContent } from "../../src/content-helpers";
1818
import {
1919
ASSET_NODE_TYPE,
20-
ASSET_TYPE_SELF,
20+
LocationAssetType,
2121
LOCATION_EVENT_TYPE,
2222
TIMESTAMP_NODE_TYPE,
2323
} from "../../src/@types/location";
@@ -33,14 +33,14 @@ describe("Location", function() {
3333
uri: "geo:foo",
3434
description: undefined,
3535
});
36-
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: ASSET_TYPE_SELF });
36+
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: LocationAssetType.Self });
3737
expect(TEXT_NODE_TYPE.findIn(loc)).toEqual("txt");
3838
expect(TIMESTAMP_NODE_TYPE.findIn(loc)).toEqual(134235435);
3939
});
4040

4141
it("should create a valid location with explicit properties", function() {
4242
const loc = makeLocationContent(
43-
"txxt", "geo:bar", 134235436, "desc", "m.something");
43+
"txxt", "geo:bar", 134235436, "desc", LocationAssetType.Pin);
4444

4545
expect(loc.body).toEqual("txxt");
4646
expect(loc.msgtype).toEqual("m.location");
@@ -49,7 +49,7 @@ describe("Location", function() {
4949
uri: "geo:bar",
5050
description: "desc",
5151
});
52-
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: "m.something" });
52+
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: LocationAssetType.Pin });
5353
expect(TEXT_NODE_TYPE.findIn(loc)).toEqual("txxt");
5454
expect(TIMESTAMP_NODE_TYPE.findIn(loc)).toEqual(134235436);
5555
});

0 commit comments

Comments
 (0)