@@ -54,8 +54,6 @@ import { MatrixError } from "./http-api/errors.ts";
54
54
import { User } from "./models/user.ts" ;
55
55
import { Room } from "./models/room.ts" ;
56
56
import { ToDeviceBatch , ToDevicePayload } from "./models/ToDeviceMessage.ts" ;
57
- import { DeviceInfo } from "./crypto/deviceinfo.ts" ;
58
- import { IOlmDevice } from "./crypto/algorithms/megolm.ts" ;
59
57
import { MapWithDefault , recursiveMapToObject } from "./utils.ts" ;
60
58
import { TypedEventEmitter } from "./matrix.ts" ;
61
59
@@ -64,6 +62,17 @@ interface IStateEventRequest {
64
62
stateKey ?: string ;
65
63
}
66
64
65
+ export interface OlmDevice {
66
+ /**
67
+ * The user ID of the device owner.
68
+ */
69
+ userId : string ;
70
+ /**
71
+ * The device ID of the device.
72
+ */
73
+ deviceId : string ;
74
+ }
75
+
67
76
export interface ICapabilities {
68
77
/**
69
78
* Event types that this client expects to send.
@@ -128,6 +137,7 @@ export enum RoomWidgetClientEvent {
128
137
PendingEventsChanged = "PendingEvent.pendingEventsChanged" ,
129
138
}
130
139
export type EventHandlerMap = { [ RoomWidgetClientEvent . PendingEventsChanged ] : ( ) => void } ;
140
+
131
141
/**
132
142
* A MatrixClient that routes its requests through the widget API instead of the
133
143
* real CS API.
@@ -466,13 +476,10 @@ export class RoomWidgetClient extends MatrixClient {
466
476
await this . widgetApi . sendToDevice ( eventType , false , recursiveMapToObject ( contentMap ) ) ;
467
477
}
468
478
469
- public async encryptAndSendToDevices ( userDeviceInfoArr : IOlmDevice < DeviceInfo > [ ] , payload : object ) : Promise < void > {
479
+ public async encryptAndSendToDevices ( userDeviceInfoArr : OlmDevice [ ] , payload : object ) : Promise < void > {
470
480
// map: user Id → device Id → payload
471
481
const contentMap : MapWithDefault < string , Map < string , object > > = new MapWithDefault ( ( ) => new Map ( ) ) ;
472
- for ( const {
473
- userId,
474
- deviceInfo : { deviceId } ,
475
- } of userDeviceInfoArr ) {
482
+ for ( const { userId, deviceId } of userDeviceInfoArr ) {
476
483
contentMap . getOrCreate ( userId ) . set ( deviceId , payload ) ;
477
484
}
478
485
0 commit comments