forked from mystiq/hydrogen-web
WIP
This commit is contained in:
parent
5d12aef6db
commit
d0d1f68a9c
1 changed files with 18 additions and 6 deletions
|
@ -43,15 +43,27 @@ export class Encryption {
|
|||
}
|
||||
}
|
||||
|
||||
async ensureOutboundSession(roomId, encryptionParams, txn) {
|
||||
async ensureOutboundSession(roomId, encryptionParams) {
|
||||
let session = new this._olm.OutboundGroupSession();
|
||||
try {
|
||||
const txn = this._storage.readWriteTxn([
|
||||
this._storage.storeNames.inboundGroupSessions,
|
||||
this._storage.storeNames.outboundGroupSessions,
|
||||
]);
|
||||
let roomKeyMessage;
|
||||
try {
|
||||
let sessionEntry = await txn.outboundGroupSessions.get(roomId);
|
||||
const roomKeyMessage = this._readOrCreateSession(session, sessionEntry, roomId, encryptionParams, txn);
|
||||
roomKeyMessage = this._readOrCreateSession(session, sessionEntry, roomId, encryptionParams, txn);
|
||||
if (roomKeyMessage) {
|
||||
this._writeSession(sessionEntry, session, roomId, txn);
|
||||
return roomKeyMessage;
|
||||
}
|
||||
} catch (err) {
|
||||
txn.abort();
|
||||
throw err;
|
||||
}
|
||||
await txn.complete();
|
||||
return roomKeyMessage;
|
||||
} finally {
|
||||
session.free();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue