Skip to content

Commit 0e30159

Browse files
committed
Merge tag 'v15.5.0' into sc
* Support m.asset in m.location event content ([\matrix-org#2109](matrix-org#2109)). * Send extensible events structure and support on-demand parsing ([\matrix-org#2091](matrix-org#2091)). * Support cancelling events whilst they are in status = ENCRYPTING ([\matrix-org#2095](matrix-org#2095)). * Fix http-api butchering idServer requests ([\matrix-org#2134](matrix-org#2134)). Fixes element-hq/element-web#20680. * Don't remove streams that still have tracks ([\matrix-org#2104](matrix-org#2104)).
2 parents 5c6b029 + ede0f69 commit 0e30159

26 files changed

+1841
-1151
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
Changes in [15.5.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.5.0) (2022-01-31)
2+
==================================================================================================
3+
4+
## ✨ Features
5+
* Support m.asset in m.location event content ([\#2109](https://github.com/matrix-org/matrix-js-sdk/pull/2109)).
6+
* Send extensible events structure and support on-demand parsing ([\#2091](https://github.com/matrix-org/matrix-js-sdk/pull/2091)).
7+
* Support cancelling events whilst they are in status = ENCRYPTING ([\#2095](https://github.com/matrix-org/matrix-js-sdk/pull/2095)).
8+
9+
## 🐛 Bug Fixes
10+
* Fix http-api butchering idServer requests ([\#2134](https://github.com/matrix-org/matrix-js-sdk/pull/2134)). Fixes vector-im/element-web#20680.
11+
* Don't remove streams that still have tracks ([\#2104](https://github.com/matrix-org/matrix-js-sdk/pull/2104)).
12+
13+
Changes in [15.5.0-rc.1](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.5.0-rc.1) (2022-01-26)
14+
============================================================================================================
15+
16+
## ✨ Features
17+
* Support m.asset in m.location event content ([\#2109](https://github.com/matrix-org/matrix-js-sdk/pull/2109)).
18+
* Send extensible events structure and support on-demand parsing ([\#2091](https://github.com/matrix-org/matrix-js-sdk/pull/2091)).
19+
* Support cancelling events whilst they are in status = ENCRYPTING ([\#2095](https://github.com/matrix-org/matrix-js-sdk/pull/2095)).
20+
21+
## 🐛 Bug Fixes
22+
* Fix http-api butchering idServer requests ([\#2134](https://github.com/matrix-org/matrix-js-sdk/pull/2134)). Fixes vector-im/element-web#20680.
23+
* Don't remove streams that still have tracks ([\#2104](https://github.com/matrix-org/matrix-js-sdk/pull/2104)).
24+
125
Changes in [15.4.0](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v15.4.0) (2022-01-17)
226
==================================================================================================
327

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "matrix-js-sdk",
3-
"version": "15.4.0",
3+
"version": "15.5.0",
44
"description": "Matrix Client-Server SDK for Javascript",
55
"scripts": {
66
"prepublishOnly": "yarn build",
@@ -56,6 +56,7 @@
5656
"bs58": "^4.0.1",
5757
"content-type": "^1.0.4",
5858
"loglevel": "^1.7.1",
59+
"matrix-events-sdk": "^0.0.1-beta.6",
5960
"p-retry": "^4.5.0",
6061
"qs": "^6.9.6",
6162
"request": "^2.88.2",

spec/integ/matrix-client-crypto.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ function recvMessage(httpBackend, client, sender, message) {
348348
return testUtils.awaitDecryption(event);
349349
}).then((event) => {
350350
expect(event.getType()).toEqual("m.room.message");
351-
expect(event.getContent()).toEqual({
351+
expect(event.getContent()).toMatchObject({
352352
msgtype: "m.text",
353353
body: "Hello, World",
354354
});

spec/test-utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,5 @@ export function setHttpResponses(
365365
.respond(200, response.data);
366366
});
367367
}
368+
369+
export const emitPromise = (e, k) => new Promise(r => e.once(k, r));

spec/unit/location.spec.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Copyright 2022 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { makeLocationContent } from "../../src/content-helpers";
18+
import {
19+
ASSET_NODE_TYPE,
20+
ASSET_TYPE_SELF,
21+
LOCATION_EVENT_TYPE,
22+
TIMESTAMP_NODE_TYPE,
23+
} from "../../src/@types/location";
24+
import { TEXT_NODE_TYPE } from "../../src/@types/extensible_events";
25+
26+
describe("Location", function() {
27+
it("should create a valid location with defaults", function() {
28+
const loc = makeLocationContent("txt", "geo:foo", 134235435);
29+
expect(loc.body).toEqual("txt");
30+
expect(loc.msgtype).toEqual("m.location");
31+
expect(loc.geo_uri).toEqual("geo:foo");
32+
expect(LOCATION_EVENT_TYPE.findIn(loc)).toEqual({
33+
uri: "geo:foo",
34+
description: undefined,
35+
});
36+
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: ASSET_TYPE_SELF });
37+
expect(TEXT_NODE_TYPE.findIn(loc)).toEqual("txt");
38+
expect(TIMESTAMP_NODE_TYPE.findIn(loc)).toEqual(134235435);
39+
});
40+
41+
it("should create a valid location with explicit properties", function() {
42+
const loc = makeLocationContent(
43+
"txxt", "geo:bar", 134235436, "desc", "m.something");
44+
45+
expect(loc.body).toEqual("txxt");
46+
expect(loc.msgtype).toEqual("m.location");
47+
expect(loc.geo_uri).toEqual("geo:bar");
48+
expect(LOCATION_EVENT_TYPE.findIn(loc)).toEqual({
49+
uri: "geo:bar",
50+
description: "desc",
51+
});
52+
expect(ASSET_NODE_TYPE.findIn(loc)).toEqual({ type: "m.something" });
53+
expect(TEXT_NODE_TYPE.findIn(loc)).toEqual("txxt");
54+
expect(TIMESTAMP_NODE_TYPE.findIn(loc)).toEqual(134235436);
55+
});
56+
});

spec/unit/matrix-client.spec.js

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
UNSTABLE_MSC3089_TREE_SUBTYPE,
1212
} from "../../src/@types/event";
1313
import { MEGOLM_ALGORITHM } from "../../src/crypto/olmlib";
14-
import { MatrixEvent } from "../../src/models/event";
14+
import { EventStatus, MatrixEvent } from "../../src/models/event";
1515
import { Preset } from "../../src/@types/partials";
16+
import * as testUtils from "../test-utils";
1617

1718
jest.useFakeTimers();
1819

@@ -713,6 +714,7 @@ describe("MatrixClient", function() {
713714
describe("guest rooms", function() {
714715
it("should only do /sync calls (without filter/pushrules)", function(done) {
715716
httpLookups = []; // no /pushrules or /filterw
717+
httpLookups.push(CAPABILITIES_RESPONSE);
716718
httpLookups.push({
717719
method: "GET",
718720
path: "/sync",
@@ -867,4 +869,83 @@ describe("MatrixClient", function() {
867869
await client.redactEvent(roomId, eventId, txnId, { reason });
868870
});
869871
});
872+
873+
describe("cancelPendingEvent", () => {
874+
const roomId = "!room:server";
875+
const txnId = "m12345";
876+
877+
const mockRoom = {
878+
getMyMembership: () => "join",
879+
updatePendingEvent: (event, status) => event.setStatus(status),
880+
currentState: {
881+
getStateEvents: (eventType, stateKey) => {
882+
if (eventType === EventType.RoomCreate) {
883+
expect(stateKey).toEqual("");
884+
return new MatrixEvent({
885+
content: {
886+
[RoomCreateTypeField]: RoomType.Space,
887+
},
888+
});
889+
} else if (eventType === EventType.RoomEncryption) {
890+
expect(stateKey).toEqual("");
891+
return new MatrixEvent({ content: {} });
892+
} else {
893+
throw new Error("Unexpected event type or state key");
894+
}
895+
},
896+
},
897+
};
898+
899+
let event;
900+
beforeEach(async () => {
901+
event = new MatrixEvent({
902+
event_id: "~" + roomId + ":" + txnId,
903+
user_id: client.credentials.userId,
904+
sender: client.credentials.userId,
905+
room_id: roomId,
906+
origin_server_ts: new Date().getTime(),
907+
});
908+
event.setTxnId(txnId);
909+
910+
client.getRoom = (getRoomId) => {
911+
expect(getRoomId).toEqual(roomId);
912+
return mockRoom;
913+
};
914+
client.crypto = { // mock crypto
915+
encryptEvent: (event, room) => new Promise(() => {}),
916+
};
917+
});
918+
919+
function assertCancelled() {
920+
expect(event.status).toBe(EventStatus.CANCELLED);
921+
expect(client.scheduler.removeEventFromQueue(event)).toBeFalsy();
922+
expect(httpLookups.filter(h => h.path.includes("/send/")).length).toBe(0);
923+
}
924+
925+
it("should cancel an event which is queued", () => {
926+
event.setStatus(EventStatus.QUEUED);
927+
client.scheduler.queueEvent(event);
928+
client.cancelPendingEvent(event);
929+
assertCancelled();
930+
});
931+
932+
it("should cancel an event which is encrypting", async () => {
933+
client.encryptAndSendEvent(null, event);
934+
await testUtils.emitPromise(event, "Event.status");
935+
client.cancelPendingEvent(event);
936+
assertCancelled();
937+
});
938+
939+
it("should cancel an event which is not sent", () => {
940+
event.setStatus(EventStatus.NOT_SENT);
941+
client.cancelPendingEvent(event);
942+
assertCancelled();
943+
});
944+
945+
it("should error when given any other event status", () => {
946+
event.setStatus(EventStatus.SENDING);
947+
expect(() => client.cancelPendingEvent(event)).toThrow("cannot cancel an event with status sending");
948+
expect(event.status).toBe(EventStatus.SENDING);
949+
});
950+
});
870951
});

spec/unit/room-state.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe("RoomState", function() {
120120
it("should return a single MatrixEvent if a state_key was specified",
121121
function() {
122122
const event = state.getStateEvents("m.room.member", userA);
123-
expect(event.getContent()).toEqual({
123+
expect(event.getContent()).toMatchObject({
124124
membership: "join",
125125
});
126126
});

src/@types/event.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,16 @@ export const UNSTABLE_ELEMENT_FUNCTIONAL_USERS = new UnstableValue(
177177
"io.element.functional_members",
178178
"io.element.functional_members");
179179

180+
/**
181+
* A type of message that affects visibility of a message,
182+
* as per https://github.com/matrix-org/matrix-doc/pull/3531
183+
*
184+
* @experimental
185+
*/
186+
export const EVENT_VISIBILITY_CHANGE_TYPE = new UnstableValue(
187+
"m.visibility",
188+
"org.matrix.msc3531.visibility");
189+
180190
export interface IEncryptedFile {
181191
url: string;
182192
mimetype?: string;

src/@types/location.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ import { TEXT_NODE_TYPE } from "./extensible_events";
2323
export const LOCATION_EVENT_TYPE = new UnstableValue(
2424
"m.location", "org.matrix.msc3488.location");
2525

26+
export const ASSET_NODE_TYPE = new UnstableValue("m.asset", "org.matrix.msc3488.asset");
27+
2628
export const TIMESTAMP_NODE_TYPE = new UnstableValue("m.ts", "org.matrix.msc3488.ts");
2729

30+
export const ASSET_TYPE_SELF = "m.self";
31+
2832
/* From the spec at:
2933
* https://github.com/matrix-org/matrix-doc/blob/matthew/location/proposals/3488-location.md
3034
{
@@ -37,6 +41,9 @@ export const TIMESTAMP_NODE_TYPE = new UnstableValue("m.ts", "org.matrix.msc3488
3741
"uri": "geo:51.5008,0.1247;u=35",
3842
"description": "Matthew's whereabouts",
3943
},
44+
"m.asset": {
45+
"type": "m.self"
46+
},
4047
"m.text": "Matthew was at geo:51.5008,0.1247;u=35 as of Sat Nov 13 18:50:58 2021",
4148
"m.ts": 1636829458432,
4249
}
@@ -52,6 +59,9 @@ export interface ILocationContent extends IContent {
5259
uri: string;
5360
description?: string;
5461
};
62+
[ASSET_NODE_TYPE.name]: {
63+
type: string;
64+
};
5565
[TEXT_NODE_TYPE.name]: string;
5666
[TIMESTAMP_NODE_TYPE.name]: number;
5767
}

src/@types/polls.ts

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

0 commit comments

Comments
 (0)