mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
migrate encryption flag so old sessions dont send unencrypted events
This commit is contained in:
parent
4bc56cb41a
commit
2855166239
@ -9,7 +9,8 @@ export const schema = [
|
|||||||
createInitialStores,
|
createInitialStores,
|
||||||
createMemberStore,
|
createMemberStore,
|
||||||
migrateSession,
|
migrateSession,
|
||||||
createE2EEStores
|
createE2EEStores,
|
||||||
|
migrateEncryptionFlag
|
||||||
];
|
];
|
||||||
// TODO: how to deal with git merge conflicts of this array?
|
// TODO: how to deal with git merge conflicts of this array?
|
||||||
|
|
||||||
@ -77,3 +78,22 @@ function createE2EEStores(db) {
|
|||||||
const operations = db.createObjectStore("operations", {keyPath: "id"});
|
const operations = db.createObjectStore("operations", {keyPath: "id"});
|
||||||
operations.createIndex("byTypeAndScope", "typeScopeKey", {unique: false});
|
operations.createIndex("byTypeAndScope", "typeScopeKey", {unique: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// v5
|
||||||
|
async function migrateEncryptionFlag(db, txn) {
|
||||||
|
// migrate room summary isEncrypted -> encryption prop
|
||||||
|
const roomSummary = txn.objectStore("roomSummary");
|
||||||
|
const roomState = txn.objectStore("roomState");
|
||||||
|
const summaries = [];
|
||||||
|
await iterateCursor(roomSummary.openCursor(), summary => {
|
||||||
|
summaries.push(summary);
|
||||||
|
});
|
||||||
|
for (const summary of summaries) {
|
||||||
|
const encryptionEntry = await reqAsPromise(roomState.get(`${summary.roomId}|m.room.encryption|`));
|
||||||
|
if (encryptionEntry) {
|
||||||
|
summary.encryption = encryptionEntry?.event?.content;
|
||||||
|
delete summary.isEncrypted;
|
||||||
|
roomSummary.put(summary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user