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();
|
let session = new this._olm.OutboundGroupSession();
|
||||||
try {
|
try {
|
||||||
let sessionEntry = await txn.outboundGroupSessions.get(roomId);
|
const txn = this._storage.readWriteTxn([
|
||||||
const roomKeyMessage = this._readOrCreateSession(session, sessionEntry, roomId, encryptionParams, txn);
|
this._storage.storeNames.inboundGroupSessions,
|
||||||
if (roomKeyMessage) {
|
this._storage.storeNames.outboundGroupSessions,
|
||||||
this._writeSession(sessionEntry, session, roomId, txn);
|
]);
|
||||||
return roomKeyMessage;
|
let roomKeyMessage;
|
||||||
|
try {
|
||||||
|
let sessionEntry = await txn.outboundGroupSessions.get(roomId);
|
||||||
|
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 {
|
} finally {
|
||||||
session.free();
|
session.free();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue