Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 4010927

Browse files
authored
Remove references to MatrixClient.crypto (#134)
* Remove `VerificationExplorer` * Remove `remakeolm` slash command * Remove call to `crypto.cancelAndResendAllOutgoingKeyRequests` * Remove crypto mock in `LoginWithQR-test.tsx` * Remove `StopGadWidgetDriver.sendToDevice` * Remove remaining mock
1 parent 99a2f63 commit 4010927

File tree

12 files changed

+0
-380
lines changed

12 files changed

+0
-380
lines changed

src/SlashCommands.tsx

-28
Original file line numberDiff line numberDiff line change
@@ -736,34 +736,6 @@ export const Commands = [
736736
category: CommandCategories.advanced,
737737
renderingTypes: [TimelineRenderingType.Room],
738738
}),
739-
new Command({
740-
command: "remakeolm",
741-
description: _td("slash_command|remakeolm"),
742-
isEnabled: (cli) => {
743-
return SettingsStore.getValue("developerMode") && !isCurrentLocalRoom(cli);
744-
},
745-
runFn: (cli, roomId) => {
746-
try {
747-
const room = cli.getRoom(roomId);
748-
749-
cli.forceDiscardSession(roomId);
750-
751-
return success(
752-
room?.getEncryptionTargetMembers().then((members) => {
753-
// noinspection JSIgnoredPromiseFromCall
754-
cli.crypto?.ensureOlmSessionsForUsers(
755-
members.map((m) => m.userId),
756-
true,
757-
);
758-
}),
759-
);
760-
} catch (e) {
761-
return reject(e instanceof Error ? e.message : e);
762-
}
763-
},
764-
category: CommandCategories.advanced,
765-
renderingTypes: [TimelineRenderingType.Room],
766-
}),
767739
new Command({
768740
command: "rainbow",
769741
description: _td("slash_command|rainbow"),

src/components/views/dialogs/DevtoolsDialog.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import MatrixClientContext from "../../../contexts/MatrixClientContext";
1414
import BaseDialog from "./BaseDialog";
1515
import { TimelineEventEditor } from "./devtools/Event";
1616
import ServersInRoom from "./devtools/ServersInRoom";
17-
import VerificationExplorer from "./devtools/VerificationExplorer";
1817
import SettingExplorer from "./devtools/SettingExplorer";
1918
import { RoomStateExplorer } from "./devtools/RoomState";
2019
import BaseTool, { DevtoolsContext, IDevtoolsProps } from "./devtools/BaseTool";
@@ -45,7 +44,6 @@ const Tools: Record<Category, [label: TranslationKey, tool: Tool][]> = {
4544
[_td("devtools|explore_room_account_data"), RoomAccountDataExplorer],
4645
[_td("devtools|view_servers_in_room"), ServersInRoom],
4746
[_td("devtools|notifications_debug"), RoomNotifications],
48-
[_td("devtools|verification_explorer"), VerificationExplorer],
4947
[_td("devtools|active_widgets"), WidgetExplorer],
5048
],
5149
[Category.Other]: [

src/components/views/dialogs/devtools/VerificationExplorer.tsx

-98
This file was deleted.

src/i18n/strings/en_EN.json

-14
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,6 @@
576576
"unmute": "Unmute",
577577
"unnamed_room": "Unnamed Room",
578578
"unnamed_space": "Unnamed Space",
579-
"unsent": "Unsent",
580579
"unverified": "Unverified",
581580
"updating": "Updating...",
582581
"user": "User",
@@ -760,20 +759,11 @@
760759
"low_bandwidth_mode": "Low bandwidth mode",
761760
"low_bandwidth_mode_description": "Requires compatible homeserver.",
762761
"main_timeline": "Main timeline",
763-
"methods": "Methods",
764762
"no_receipt_found": "No receipt found",
765-
"no_verification_requests_found": "No verification requests found",
766763
"notification_state": "Notification state is <strong>%(notificationState)s</strong>",
767764
"notifications_debug": "Notifications debug",
768765
"number_of_users": "Number of users",
769766
"original_event_source": "Original event source",
770-
"other_user": "Other user",
771-
"phase": "Phase",
772-
"phase_cancelled": "Cancelled",
773-
"phase_ready": "Ready",
774-
"phase_requested": "Requested",
775-
"phase_started": "Started",
776-
"phase_transaction": "Transaction",
777767
"room_encrypted": "Room is <strong>encrypted ✅</strong>",
778768
"room_id": "Room ID: %(roomId)s",
779769
"room_not_encrypted": "Room is <strong>not encrypted 🚨</strong>",
@@ -811,8 +801,6 @@
811801
"state_key": "State Key",
812802
"thread_root_id": "Thread Root ID: %(threadRootId)s",
813803
"threads_timeline": "Threads timeline",
814-
"timeout": "Timeout",
815-
"timeout_none": "None",
816804
"title": "Developer tools",
817805
"toggle_event": "toggle event",
818806
"toolbox": "Toolbox",
@@ -829,7 +817,6 @@
829817
"values_explicit_colon": "Values at explicit levels:",
830818
"values_explicit_room": "Values at explicit levels in this room",
831819
"values_explicit_this_room_colon": "Values at explicit levels in this room:",
832-
"verification_explorer": "Verification explorer",
833820
"view_servers_in_room": "View servers in room",
834821
"view_source_decrypted_event_source": "Decrypted event source",
835822
"view_source_decrypted_event_source_unavailable": "Decrypted source unavailable",
@@ -3013,7 +3000,6 @@
30133000
"rageshake": "Send a bug report with logs",
30143001
"rainbow": "Sends the given message coloured as a rainbow",
30153002
"rainbowme": "Sends the given emote coloured as a rainbow",
3016-
"remakeolm": "Developer command: Discards the current outbound group session and sets up new Olm sessions",
30173003
"remove": "Removes user with given id from this room",
30183004
"roomavatar": "Changes the avatar of the current room",
30193005
"roomname": "Sets the room name",

src/stores/SetupEncryptionStore.ts

-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ export class SetupEncryptionStore extends EventEmitter {
284284
public done(): void {
285285
this.phase = Phase.Finished;
286286
this.emit("update");
287-
// async - ask other clients for keys, if necessary
288-
MatrixClientPeg.safeGet().crypto?.cancelAndResendAllOutgoingKeyRequests();
289287
}
290288

291289
private async setActiveVerificationRequest(request: VerificationRequest): Promise<void> {

src/stores/widgets/StopGapWidgetDriver.ts

-49
Original file line numberDiff line numberDiff line change
@@ -414,55 +414,6 @@ export class StopGapWidgetDriver extends WidgetDriver {
414414
await client._unstable_updateDelayedEvent(delayId, action);
415415
}
416416

417-
public async sendToDevice(
418-
eventType: string,
419-
encrypted: boolean,
420-
contentMap: { [userId: string]: { [deviceId: string]: object } },
421-
): Promise<void> {
422-
const client = MatrixClientPeg.safeGet();
423-
424-
if (encrypted) {
425-
const deviceInfoMap = await client.crypto!.deviceList.downloadKeys(Object.keys(contentMap), false);
426-
427-
await Promise.all(
428-
Object.entries(contentMap).flatMap(([userId, userContentMap]) =>
429-
Object.entries(userContentMap).map(async ([deviceId, content]): Promise<void> => {
430-
const devices = deviceInfoMap.get(userId);
431-
if (!devices) return;
432-
433-
if (deviceId === "*") {
434-
// Send the message to all devices we have keys for
435-
await client.encryptAndSendToDevices(
436-
Array.from(devices.values()).map((deviceInfo) => ({
437-
userId,
438-
deviceInfo,
439-
})),
440-
content,
441-
);
442-
} else if (devices.has(deviceId)) {
443-
// Send the message to a specific device
444-
await client.encryptAndSendToDevices(
445-
[{ userId, deviceInfo: devices.get(deviceId)! }],
446-
content,
447-
);
448-
}
449-
}),
450-
),
451-
);
452-
} else {
453-
await client.queueToDevice({
454-
eventType,
455-
batch: Object.entries(contentMap).flatMap(([userId, userContentMap]) =>
456-
Object.entries(userContentMap).map(([deviceId, content]) => ({
457-
userId,
458-
deviceId,
459-
payload: content,
460-
})),
461-
),
462-
});
463-
}
464-
}
465-
466417
private pickRooms(roomIds?: (string | Symbols.AnyRoom)[]): Room[] {
467418
const client = MatrixClientPeg.get();
468419
if (!client) throw new Error("Not attached to a client");

test/SlashCommands-test.tsx

-44
Original file line numberDiff line numberDiff line change
@@ -236,50 +236,6 @@ describe("SlashCommands", () => {
236236
});
237237
});
238238

239-
describe("/remakeolm", () => {
240-
beforeEach(() => {
241-
command = findCommand("remakeolm")!;
242-
});
243-
244-
describe("isEnabled", () => {
245-
describe("when developer mode is enabled", () => {
246-
beforeEach(() => {
247-
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => {
248-
if (settingName === "developerMode") return true;
249-
});
250-
});
251-
252-
it("should return true for Room", () => {
253-
setCurrentRoom();
254-
expect(command.isEnabled(client)).toBe(true);
255-
});
256-
257-
it("should return false for LocalRoom", () => {
258-
setCurrentLocalRoom();
259-
expect(command.isEnabled(client)).toBe(false);
260-
});
261-
});
262-
263-
describe("when developer mode is not enabled", () => {
264-
beforeEach(() => {
265-
jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName: string) => {
266-
if (settingName === "developerMode") return false;
267-
});
268-
});
269-
270-
it("should return false for Room", () => {
271-
setCurrentRoom();
272-
expect(command.isEnabled(client)).toBe(false);
273-
});
274-
275-
it("should return false for LocalRoom", () => {
276-
setCurrentLocalRoom();
277-
expect(command.isEnabled(client)).toBe(false);
278-
});
279-
});
280-
});
281-
});
282-
283239
describe("/part", () => {
284240
it("should part room matching alias if found", async () => {
285241
const room1 = new Room("room-id", client, client.getSafeUserId());

test/components/views/dialogs/__snapshots__/DevtoolsDialog-test.tsx.snap

-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ exports[`DevtoolsDialog renders the devtools dialog 1`] = `
7575
>
7676
Notifications debug
7777
</button>
78-
<button
79-
class="mx_DevTools_button"
80-
>
81-
Verification explorer
82-
</button>
8378
<button
8479
class="mx_DevTools_button"
8580
>

test/components/views/settings/devices/LoginWithQR-test.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function makeClient() {
5151
},
5252
getClientWellKnown: jest.fn().mockReturnValue({}),
5353
getCrypto: jest.fn().mockReturnValue({}),
54-
crypto: {},
5554
} as unknown as MatrixClient);
5655
}
5756

@@ -194,7 +193,6 @@ describe("<LoginWithQR />", () => {
194193
});
195194

196195
test("approve - no crypto", async () => {
197-
(client as any).crypto = undefined;
198196
(client as any).getCrypto = () => undefined;
199197
const onFinished = jest.fn();
200198
render(getComponent({ client, onFinished }));

0 commit comments

Comments
 (0)