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

Commit ef306d2

Browse files
committed
Remove StopGadWidgetDriver.sendToDevice
1 parent d4a6c90 commit ef306d2

File tree

2 files changed

+0
-98
lines changed

2 files changed

+0
-98
lines changed

src/stores/widgets/StopGapWidgetDriver.ts

Lines changed: 0 additions & 49 deletions
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/stores/widgets/StopGapWidgetDriver-test.ts

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
MsgType,
1919
RelationType,
2020
} from "matrix-js-sdk/src/matrix";
21-
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
2221
import {
2322
Widget,
2423
MatrixWidgetType,
@@ -171,54 +170,6 @@ describe("StopGapWidgetDriver", () => {
171170
expect(listener).toHaveBeenCalledWith(openIdUpdate);
172171
});
173172

174-
describe("sendToDevice", () => {
175-
const contentMap = {
176-
"@alice:example.org": {
177-
"*": {
178-
hello: "alice",
179-
},
180-
},
181-
"@bob:example.org": {
182-
bobDesktop: {
183-
hello: "bob",
184-
},
185-
},
186-
};
187-
188-
let driver: WidgetDriver;
189-
190-
beforeEach(() => {
191-
driver = mkDefaultDriver();
192-
});
193-
194-
it("sends unencrypted messages", async () => {
195-
await driver.sendToDevice("org.example.foo", false, contentMap);
196-
expect(client.queueToDevice.mock.calls).toMatchSnapshot();
197-
});
198-
199-
it("sends encrypted messages", async () => {
200-
const aliceWeb = new DeviceInfo("aliceWeb");
201-
const aliceMobile = new DeviceInfo("aliceMobile");
202-
const bobDesktop = new DeviceInfo("bobDesktop");
203-
204-
mocked(client.crypto!.deviceList).downloadKeys.mockResolvedValue(
205-
new Map([
206-
[
207-
"@alice:example.org",
208-
new Map([
209-
["aliceWeb", aliceWeb],
210-
["aliceMobile", aliceMobile],
211-
]),
212-
],
213-
["@bob:example.org", new Map([["bobDesktop", bobDesktop]])],
214-
]),
215-
);
216-
217-
await driver.sendToDevice("org.example.foo", true, contentMap);
218-
expect(client.encryptAndSendToDevices.mock.calls).toMatchSnapshot();
219-
});
220-
});
221-
222173
describe("getTurnServers", () => {
223174
let driver: WidgetDriver;
224175

0 commit comments

Comments
 (0)