@@ -22,6 +22,7 @@ import { Room } from "../models/room";
22
22
import { logger , PrefixedLogger } from "../logger" ;
23
23
import { KeyClaimManager } from "./KeyClaimManager" ;
24
24
import { RoomMember } from "../models/room-member" ;
25
+ import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor" ;
25
26
26
27
/**
27
28
* RoomEncryptor: responsible for encrypting messages to a given room
@@ -38,6 +39,7 @@ export class RoomEncryptor {
38
39
public constructor (
39
40
private readonly olmMachine : OlmMachine ,
40
41
private readonly keyClaimManager : KeyClaimManager ,
42
+ private readonly outgoingRequestProcessor : OutgoingRequestProcessor ,
41
43
private readonly room : Room ,
42
44
private encryptionSettings : IContent ,
43
45
) {
@@ -97,10 +99,21 @@ export class RoomEncryptor {
97
99
const userList = members . map ( ( u ) => new UserId ( u . userId ) ) ;
98
100
await this . keyClaimManager . ensureSessionsForUsers ( userList ) ;
99
101
102
+ this . prefixedLogger . debug ( "Sessions for users are ready; now sharing room key" ) ;
103
+
100
104
const rustEncryptionSettings = new EncryptionSettings ( ) ;
101
105
/* FIXME historyVisibility, rotation, etc */
102
106
103
- await this . olmMachine . shareRoomKey ( new RoomId ( this . room . roomId ) , userList , rustEncryptionSettings ) ;
107
+ const shareMessages = await this . olmMachine . shareRoomKey (
108
+ new RoomId ( this . room . roomId ) ,
109
+ userList ,
110
+ rustEncryptionSettings ,
111
+ ) ;
112
+ if ( shareMessages ) {
113
+ for ( const m of shareMessages ) {
114
+ await this . outgoingRequestProcessor . makeOutgoingRequest ( m ) ;
115
+ }
116
+ }
104
117
}
105
118
106
119
/**
0 commit comments