Skip to content

Commit 7c87625

Browse files
authored
Remove more deprecated methods, fields, and exports (#4217)
1 parent b19817b commit 7c87625

21 files changed

+47
-297
lines changed

spec/integ/crypto/megolm-backup.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Mocked } from "jest-mock";
2121

2222
import {
2323
createClient,
24-
CryptoApi,
24+
Crypto,
2525
CryptoEvent,
2626
ICreateClientOpts,
2727
IEvent,
@@ -310,7 +310,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("megolm-keys backup (%s)", (backe
310310
});
311311

312312
describe("recover from backup", () => {
313-
let aliceCrypto: CryptoApi;
313+
let aliceCrypto: Crypto.CryptoApi;
314314

315315
beforeEach(async () => {
316316
fetchMock.get("path:/_matrix/client/v3/room_keys/version", testData.SIGNED_BACKUP_DATA);

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,6 @@ function withThreadId(event: MatrixEvent, newThreadId: string): MatrixEvent {
18251825

18261826
const buildEventMessageInThread = (root: MatrixEvent) =>
18271827
new MatrixEvent({
1828-
age: 80098509,
18291828
content: {
18301829
"algorithm": "m.megolm.v1.aes-sha2",
18311830
"ciphertext": "ENCRYPTEDSTUFF",
@@ -1846,12 +1845,10 @@ const buildEventMessageInThread = (root: MatrixEvent) =>
18461845
sender: "@andybalaam-test1:matrix.org",
18471846
type: "m.room.encrypted",
18481847
unsigned: { age: 80098509 },
1849-
user_id: "@andybalaam-test1:matrix.org",
18501848
});
18511849

18521850
const buildEventPollResponseReference = () =>
18531851
new MatrixEvent({
1854-
age: 80098509,
18551852
content: {
18561853
"algorithm": "m.megolm.v1.aes-sha2",
18571854
"ciphertext": "ENCRYPTEDSTUFF",
@@ -1869,7 +1866,6 @@ const buildEventPollResponseReference = () =>
18691866
sender: "@andybalaam-test1:matrix.org",
18701867
type: "m.room.encrypted",
18711868
unsigned: { age: 80106237 },
1872-
user_id: "@andybalaam-test1:matrix.org",
18731869
});
18741870

18751871
const buildEventReaction = (event: MatrixEvent) =>
@@ -1909,7 +1905,6 @@ const buildEventRedaction = (event: MatrixEvent) =>
19091905

19101906
const buildEventPollStartThreadRoot = () =>
19111907
new MatrixEvent({
1912-
age: 80108647,
19131908
content: {
19141909
algorithm: "m.megolm.v1.aes-sha2",
19151910
ciphertext: "ENCRYPTEDSTUFF",
@@ -1923,12 +1918,10 @@ const buildEventPollStartThreadRoot = () =>
19231918
sender: "@andybalaam-test1:matrix.org",
19241919
type: "m.room.encrypted",
19251920
unsigned: { age: 80108647 },
1926-
user_id: "@andybalaam-test1:matrix.org",
19271921
});
19281922

19291923
const buildEventReply = (target: MatrixEvent) =>
19301924
new MatrixEvent({
1931-
age: 80098509,
19321925
content: {
19331926
"algorithm": "m.megolm.v1.aes-sha2",
19341927
"ciphertext": "ENCRYPTEDSTUFF",
@@ -1947,12 +1940,10 @@ const buildEventReply = (target: MatrixEvent) =>
19471940
sender: "@andybalaam-test1:matrix.org",
19481941
type: "m.room.encrypted",
19491942
unsigned: { age: 80098509 },
1950-
user_id: "@andybalaam-test1:matrix.org",
19511943
});
19521944

19531945
const buildEventRoomName = () =>
19541946
new MatrixEvent({
1955-
age: 80123249,
19561947
content: {
19571948
name: "1 poll, 1 vote, 1 thread",
19581949
},
@@ -1963,12 +1954,10 @@ const buildEventRoomName = () =>
19631954
state_key: "",
19641955
type: "m.room.name",
19651956
unsigned: { age: 80123249 },
1966-
user_id: "@andybalaam-test1:matrix.org",
19671957
});
19681958

19691959
const buildEventEncryption = () =>
19701960
new MatrixEvent({
1971-
age: 80123383,
19721961
content: {
19731962
algorithm: "m.megolm.v1.aes-sha2",
19741963
},
@@ -1979,12 +1968,10 @@ const buildEventEncryption = () =>
19791968
state_key: "",
19801969
type: "m.room.encryption",
19811970
unsigned: { age: 80123383 },
1982-
user_id: "@andybalaam-test1:matrix.org",
19831971
});
19841972

19851973
const buildEventGuestAccess = () =>
19861974
new MatrixEvent({
1987-
age: 80123473,
19881975
content: {
19891976
guest_access: "can_join",
19901977
},
@@ -1995,12 +1982,10 @@ const buildEventGuestAccess = () =>
19951982
state_key: "",
19961983
type: "m.room.guest_access",
19971984
unsigned: { age: 80123473 },
1998-
user_id: "@andybalaam-test1:matrix.org",
19991985
});
20001986

20011987
const buildEventHistoryVisibility = () =>
20021988
new MatrixEvent({
2003-
age: 80123556,
20041989
content: {
20051990
history_visibility: "shared",
20061991
},
@@ -2011,12 +1996,10 @@ const buildEventHistoryVisibility = () =>
20111996
state_key: "",
20121997
type: "m.room.history_visibility",
20131998
unsigned: { age: 80123556 },
2014-
user_id: "@andybalaam-test1:matrix.org",
20151999
});
20162000

20172001
const buildEventJoinRules = () =>
20182002
new MatrixEvent({
2019-
age: 80123696,
20202003
content: {
20212004
join_rule: KnownMembership.Invite,
20222005
},
@@ -2027,12 +2010,10 @@ const buildEventJoinRules = () =>
20272010
state_key: "",
20282011
type: "m.room.join_rules",
20292012
unsigned: { age: 80123696 },
2030-
user_id: "@andybalaam-test1:matrix.org",
20312013
});
20322014

20332015
const buildEventPowerLevels = () =>
20342016
new MatrixEvent({
2035-
age: 80124105,
20362017
content: {
20372018
ban: 50,
20382019
events: {
@@ -2063,12 +2044,10 @@ const buildEventPowerLevels = () =>
20632044
state_key: "",
20642045
type: "m.room.power_levels",
20652046
unsigned: { age: 80124105 },
2066-
user_id: "@andybalaam-test1:matrix.org",
20672047
});
20682048

20692049
const buildEventMember = () =>
20702050
new MatrixEvent({
2071-
age: 80125279,
20722051
content: {
20732052
avatar_url: "mxc://matrix.org/aNtbVcFfwotudypZcHsIcPOc",
20742053
displayname: "andybalaam-test1",
@@ -2081,12 +2060,10 @@ const buildEventMember = () =>
20812060
state_key: "@andybalaam-test1:matrix.org",
20822061
type: "m.room.member",
20832062
unsigned: { age: 80125279 },
2084-
user_id: "@andybalaam-test1:matrix.org",
20852063
});
20862064

20872065
const buildEventCreate = () =>
20882066
new MatrixEvent({
2089-
age: 80126105,
20902067
content: {
20912068
room_version: "6",
20922069
},
@@ -2097,7 +2074,6 @@ const buildEventCreate = () =>
20972074
state_key: "",
20982075
type: "m.room.create",
20992076
unsigned: { age: 80126105 },
2100-
user_id: "@andybalaam-test1:matrix.org",
21012077
});
21022078

21032079
function assertObjectContains(obj: Record<string, any>, expected: any): void {

spec/integ/matrix-client-room-timeline.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ describe("MatrixClient room timelines", function () {
333333
name: userName,
334334
url: "mxc://some/url",
335335
});
336-
oldMshipEvent.prev_content = {
336+
oldMshipEvent.unsigned!.prev_content = {
337337
displayname: "Old Alice",
338338
avatar_url: undefined,
339339
membership: KnownMembership.Join,

spec/test-utils/test-utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ export function mkEvent(opts: IEventOpts & { event?: boolean }, client?: MatrixC
173173
room_id: opts.room,
174174
sender: opts.sender || opts.user, // opts.user for backwards-compat
175175
content: opts.content,
176-
prev_content: opts.prev_content,
177-
unsigned: opts.unsigned || {},
176+
unsigned: {
177+
...opts.unsigned,
178+
prev_content: opts.prev_content,
179+
},
178180
event_id: "$" + testEventIndex++ + "-" + Math.random() + "-" + Math.random(),
179181
txn_id: "~" + Math.random(),
180182
redacts: opts.redacts,

spec/unit/autodiscovery.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ describe("AutoDiscovery", function () {
857857
const expected = {
858858
"m.homeserver": {
859859
state: AutoDiscoveryAction.FAIL_ERROR,
860-
error: AutoDiscovery.ERROR_HOMESERVER_TOO_OLD,
860+
error: AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION,
861861
base_url: "https://example.org",
862862
},
863863
"m.identity_server": {

spec/unit/event-timeline-set.spec.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ describe("EventTimelineSet", () => {
136136
expect(eventsInLiveTimeline.length).toStrictEqual(1);
137137
expect(eventsInLiveTimeline[0]).toStrictEqual(duplicateMessageEvent);
138138
});
139-
140-
it("Make sure legacy overload passing options directly as parameters still works", () => {
141-
expect(() => eventTimelineSet.addLiveEvent(messageEvent, DuplicateStrategy.Replace, false)).not.toThrow();
142-
expect(() => eventTimelineSet.addLiveEvent(messageEvent, DuplicateStrategy.Ignore, true)).not.toThrow();
143-
});
144139
});
145140

146141
describe("addEventToTimeline", () => {

spec/unit/matrix-client.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,6 @@ describe("MatrixClient", function () {
15601560
},
15611561
},
15621562
event_id: "$ev1",
1563-
user_id: "@alice:matrix.org",
15641563
});
15651564

15661565
expect(rootEvent.isThreadRoot).toBe(true);

spec/unit/room.spec.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { mocked } from "jest-mock";
2222
import { M_POLL_KIND_DISCLOSED, M_POLL_RESPONSE, M_POLL_START, Optional, PollStartEvent } from "matrix-events-sdk";
2323

2424
import * as utils from "../test-utils/test-utils";
25-
import { emitPromise } from "../test-utils/test-utils";
25+
import { emitPromise, IMessageOpts } from "../test-utils/test-utils";
2626
import {
2727
Direction,
2828
DuplicateStrategy,
@@ -54,7 +54,6 @@ import { Crypto } from "../../src/crypto";
5454
import * as threadUtils from "../test-utils/thread";
5555
import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../test-utils/client";
5656
import { logger } from "../../src/logger";
57-
import { IMessageOpts } from "../test-utils/test-utils";
5857
import { flushPromises } from "../test-utils/flushPromises";
5958
import { KnownMembership } from "../../src/@types/membership";
6059

@@ -339,24 +338,6 @@ describe("Room", function () {
339338
}),
340339
];
341340

342-
it("Make sure legacy overload passing options directly as parameters still works", async () => {
343-
await expect(room.addLiveEvents(events, DuplicateStrategy.Replace, false)).resolves.not.toThrow();
344-
await expect(room.addLiveEvents(events, DuplicateStrategy.Ignore, true)).resolves.not.toThrow();
345-
await expect(
346-
// @ts-ignore
347-
room.addLiveEvents(events, "shouldfailbecauseinvalidduplicatestrategy", false),
348-
).rejects.toThrow();
349-
});
350-
351-
it("should throw if duplicateStrategy isn't 'replace' or 'ignore'", async function () {
352-
return expect(
353-
// @ts-ignore
354-
room.addLiveEvents(events, {
355-
duplicateStrategy: "foo",
356-
}),
357-
).rejects.toThrow();
358-
});
359-
360341
it("should replace a timeline event if dupe strategy is 'replace'", async function () {
361342
// make a duplicate
362343
const dupe = utils.mkMessage({
@@ -387,7 +368,7 @@ describe("Room", function () {
387368
expect(room.timeline[0]).toEqual(events[0]);
388369
// @ts-ignore
389370
await room.addLiveEvents([dupe], {
390-
duplicateStrategy: "ignore",
371+
duplicateStrategy: DuplicateStrategy.Ignore,
391372
});
392373
expect(room.timeline[0]).toEqual(events[0]);
393374
});

src/@types/registration.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,13 @@ export interface RegisterRequest {
5252
*/
5353
initial_device_display_name?: string;
5454
/**
55-
* @deprecated missing in the spec
55+
* Guest users can also upgrade their account by going through the ordinary register flow,
56+
* but specifying the additional POST parameter guest_access_token containing the guest’s access token.
57+
* They are also required to specify the username parameter to the value of the local part of their username,
58+
* which is otherwise optional.
59+
* @see https://spec.matrix.org/v1.10/client-server-api/#guest-access
5660
*/
5761
guest_access_token?: string;
58-
/**
59-
* @deprecated missing in the spec
60-
*/
61-
x_show_msisdn?: boolean;
62-
/**
63-
* @deprecated missing in the spec
64-
*/
65-
bind_msisdn?: boolean;
66-
/**
67-
* @deprecated missing in the spec
68-
*/
69-
bind_email?: boolean;
7062
}
7163

7264
/**

src/autodiscovery.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ export enum AutoDiscoveryError {
4343
InvalidJson = "Invalid JSON",
4444
UnsupportedHomeserverSpecVersion = "The homeserver does not meet the version requirements",
4545

46-
/** @deprecated Replaced by `UnsupportedHomeserverSpecVersion` */
47-
HomeserverTooOld = UnsupportedHomeserverSpecVersion,
4846
// TODO: Implement when Sydent supports the `/versions` endpoint - https://github.com/matrix-org/sydent/issues/424
4947
//IdentityServerTooOld = "The identity server does not meet the minimum version requirements",
5048
}
@@ -91,9 +89,6 @@ export class AutoDiscovery {
9189
public static readonly ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION =
9290
AutoDiscoveryError.UnsupportedHomeserverSpecVersion;
9391

94-
/** @deprecated Replaced by ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION */
95-
public static readonly ERROR_HOMESERVER_TOO_OLD = AutoDiscovery.ERROR_UNSUPPORTED_HOMESERVER_SPEC_VERSION;
96-
9792
public static readonly ALL_ERRORS = Object.keys(AutoDiscoveryError) as AutoDiscoveryError[];
9893

9994
/**

0 commit comments

Comments
 (0)