You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
more de-linting and fixing
This commit is contained in:
@@ -264,8 +264,8 @@ MegolmEncryption.prototype._prepareNewSession = async function() {
|
||||
);
|
||||
|
||||
if (this._crypto.backupInfo) {
|
||||
// Not strictly necessary to wait for this
|
||||
await this._crypto.backupGroupSession(
|
||||
// don't wait for it to complete
|
||||
this._crypto.backupGroupSession(
|
||||
this._roomId, this._olmDevice.deviceCurve25519Key, [],
|
||||
sessionId, key.key,
|
||||
);
|
||||
@@ -849,7 +849,8 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
|
||||
this._retryDecryption(senderKey, sessionId);
|
||||
}).then(() => {
|
||||
if (this._crypto.backupInfo) {
|
||||
return this._crypto.backupGroupSession(
|
||||
// don't wait for it to complete
|
||||
this._crypto.backupGroupSession(
|
||||
content.room_id, senderKey, forwardingKeyChain,
|
||||
content.session_id, content.session_key, keysClaimed,
|
||||
exportFormat,
|
||||
@@ -972,6 +973,18 @@ MegolmDecryption.prototype.importRoomKey = function(session) {
|
||||
session.sender_claimed_keys,
|
||||
true,
|
||||
).then(() => {
|
||||
if (this._crypto.backupInfo) {
|
||||
// don't wait for it to complete
|
||||
this._crypto.backupGroupSession(
|
||||
session.room_id,
|
||||
session.sender_key,
|
||||
session.forwarding_curve25519_key_chain,
|
||||
session.session_id,
|
||||
session.session_key,
|
||||
session.sender_claimed_keys,
|
||||
true,
|
||||
);
|
||||
}
|
||||
// have another go at decrypting events sent with this session.
|
||||
this._retryDecryption(session.sender_key, session.session_id);
|
||||
});
|
||||
|
||||
@@ -1061,7 +1061,7 @@ Crypto.prototype.backupGroupSession = async function(
|
||||
sessionId: sessionId,
|
||||
}]);
|
||||
|
||||
this._maybeSendKeyBackup();
|
||||
await this._maybeSendKeyBackup();
|
||||
};
|
||||
|
||||
Crypto.prototype.backupAllGroupSessions = async function(version) {
|
||||
@@ -1077,7 +1077,7 @@ Crypto.prototype.backupAllGroupSessions = async function(version) {
|
||||
},
|
||||
);
|
||||
|
||||
this._maybeSendKeyBackup();
|
||||
await this._maybeSendKeyBackup();
|
||||
};
|
||||
|
||||
/* eslint-disable valid-jsdoc */ //https://github.com/eslint/eslint/issues/7307
|
||||
|
||||
@@ -501,7 +501,6 @@ export class Backend {
|
||||
const objectStore = txn.objectStore("sessions_needing_backup");
|
||||
return Promise.all(sessions.map((session) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(session);
|
||||
const req = objectStore.delete([session.senderKey, session.sessionId]);
|
||||
req.onsuccess = resolve;
|
||||
req.onerror = reject;
|
||||
|
||||
@@ -167,43 +167,52 @@ export default class LocalStorageCryptoStore extends MemoryCryptoStore {
|
||||
}
|
||||
|
||||
getSessionsNeedingBackup(limit) {
|
||||
const sessionsNeedingBackup
|
||||
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||
const sessions = [];
|
||||
|
||||
for (const session in getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP)) {
|
||||
for (const session in sessionsNeedingBackup) {
|
||||
if (Object.prototype.hasOwnProperty.call(sessionsNeedingBackup, session)) {
|
||||
const senderKey = session.substr(0, 43);
|
||||
const sessionId = session.substr(44);
|
||||
getEndToEndInboundGroupSession(senderKey, sessionId, null, (sessionData) => {
|
||||
this.getEndToEndInboundGroupSession(
|
||||
senderKey, sessionId, null,
|
||||
(sessionData) => {
|
||||
sessions.push({
|
||||
senderKey: senderKey,
|
||||
sessionId: sessionId,
|
||||
sessionData: sessionData,
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
if (limit && session.length >= limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Promise.resolve(sessions);
|
||||
}
|
||||
|
||||
unmarkSessionsNeedingBackup(sessions) {
|
||||
const sessionsNeedingBackup = getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||
for(const session of sessions) {
|
||||
const sessionsNeedingBackup
|
||||
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||
for (const session of sessions) {
|
||||
delete sessionsNeedingBackup[session.senderKey + '/' + session.sessionId];
|
||||
}
|
||||
setJsonItem(
|
||||
this.store, KEY_SESSION_NEEDING_BACKUP, sessionsNeedinBackup,
|
||||
this.store, KEY_SESSIONS_NEEDING_BACKUP, sessionsNeedingBackup,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
markSessionsNeedingBackup(sessions) {
|
||||
const sessionsNeedingBackup = getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||
for(const session of sessions) {
|
||||
const sessionsNeedingBackup
|
||||
= getJsonItem(this.store, KEY_SESSIONS_NEEDING_BACKUP) || {};
|
||||
for (const session of sessions) {
|
||||
sessionsNeedingBackup[session.senderKey + '/' + session.sessionId] = true;
|
||||
}
|
||||
setJsonItem(
|
||||
this.store, KEY_SESSION_NEEDING_BACKUP, sessionsNeedinBackup,
|
||||
this.store, KEY_SESSIONS_NEEDING_BACKUP, sessionsNeedingBackup,
|
||||
);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
@@ -315,15 +315,17 @@ export default class MemoryCryptoStore {
|
||||
}
|
||||
|
||||
unmarkSessionsNeedingBackup(sessions) {
|
||||
for(const session of sessions) {
|
||||
delete this._sessionsNeedingBackup[session.senderKey + '/' + session.sessionId];
|
||||
for (const session of sessions) {
|
||||
const sessionKey = session.senderKey + '/' + session.sessionId;
|
||||
delete this._sessionsNeedingBackup[sessionKey];
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
markSessionsNeedingBackup(sessions) {
|
||||
for(const session of sessions) {
|
||||
this._sessionsNeedingBackup[session.senderKey + '/' + session.sessionId] = true;
|
||||
for (const session of sessions) {
|
||||
const sessionKey = session.senderKey + '/' + session.sessionId;
|
||||
this._sessionsNeedingBackup[sessionKey] = true;
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user