3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-07-08 03:27:20 +00:00

perf: move encryption/decryption to a separate thread

This commit is contained in:
Dragory 2021-10-09 14:21:23 +03:00
parent 0b337a13a4
commit b7c7e002eb
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
16 changed files with 310 additions and 147 deletions

View file

@ -9,7 +9,7 @@ export class EncryptExistingMessages1600283341726 implements MigrationInterface
// 2. Encrypt all permanent messages
const messages = await queryRunner.query("SELECT id, data FROM messages");
for (const message of messages) {
const encryptedData = encrypt(message.data);
const encryptedData = await encrypt(message.data);
await queryRunner.query("UPDATE messages SET data = ? WHERE id = ?", [encryptedData, message.id]);
}
}
@ -18,7 +18,7 @@ export class EncryptExistingMessages1600283341726 implements MigrationInterface
// Decrypt all messages
const messages = await queryRunner.query("SELECT id, data FROM messages");
for (const message of messages) {
const decryptedData = decrypt(message.data);
const decryptedData = await decrypt(message.data);
await queryRunner.query("UPDATE messages SET data = ? WHERE id = ?", [decryptedData, message.id]);
}
}