Page MenuHomePhorge

D9427.1768344266.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D9427.1768344266.diff

diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js
--- a/keyserver/src/database/migration-config.js
+++ b/keyserver/src/database/migration-config.js
@@ -11,10 +11,14 @@
import { processMessagesInDBForSearch } from '../database/search-utils.js';
import { deleteThread } from '../deleters/thread-deleters.js';
import { createScriptViewer } from '../session/scripts.js';
+import { fetchOlmAccount } from '../updaters/olm-account-updater.js';
import { updateRolesAndPermissionsForAllThreads } from '../updaters/thread-permission-updaters.js';
import { updateThread } from '../updaters/thread-updaters.js';
import { ensureUserCredentials } from '../user/checks.js';
-import { createPickledOlmAccount } from '../utils/olm-utils.js';
+import {
+ createPickledOlmAccount,
+ publishPrekeysToIdentity,
+} from '../utils/olm-utils.js';
const botViewer = createScriptViewer(bots.commbot.userID);
@@ -557,6 +561,23 @@
`,
),
],
+ [
+ 46,
+ async () => {
+ try {
+ const [content, notif] = await Promise.all([
+ fetchOlmAccount('content'),
+ fetchOlmAccount('notifications'),
+ ]);
+ await publishPrekeysToIdentity(content.account, notif.account);
+ } catch (e) {
+ console.warn('Encountered error while trying to publish prekeys', e);
+ if (process.env.ENV === 'prod') {
+ throw e;
+ }
+ }
+ },
+ ],
]);
const newDatabaseVersion: number = Math.max(...migrations.keys());
diff --git a/keyserver/src/utils/olm-utils.js b/keyserver/src/utils/olm-utils.js
--- a/keyserver/src/utils/olm-utils.js
+++ b/keyserver/src/utils/olm-utils.js
@@ -203,7 +203,11 @@
): Promise<void> {
// Since keys are rotated synchronously, only check validity of one
if (shouldRotatePrekey(contentAccount)) {
- await publishNewPrekeys(contentAccount, notifAccount);
+ contentAccount.generate_prekey();
+ notifAccount.generate_prekey();
+ await publishPrekeysToIdentity(contentAccount, notifAccount);
+ contentAccount.mark_prekey_as_published();
+ notifAccount.mark_prekey_as_published();
}
if (shouldForgetPrekey(contentAccount)) {
contentAccount.forget_old_prekey();
@@ -211,20 +215,16 @@
}
}
-async function publishNewPrekeys(
+async function publishPrekeysToIdentity(
contentAccount: OlmAccount,
notifAccount: OlmAccount,
): Promise<void> {
const rustAPIPromise = getRustAPI();
const fetchIdentityInfoPromise = fetchIdentityInfo();
-
const deviceID = JSON.parse(contentAccount.identity_keys()).ed25519;
- contentAccount.generate_prekey();
const { prekey: contentPrekey, prekeySignature: contentPrekeySignature } =
getAccountPrekeysSet(contentAccount);
-
- notifAccount.generate_prekey();
const { prekey: notifPrekey, prekeySignature: notifPrekeySignature } =
getAccountPrekeysSet(notifAccount);
@@ -254,9 +254,6 @@
notifPrekey,
notifPrekeySignature,
);
-
- contentAccount.mark_prekey_as_published();
- notifAccount.mark_prekey_as_published();
}
export {
@@ -270,4 +267,5 @@
getContentSigningKey,
getAccountPrekeysSet,
validateAndUploadAccountPrekeys,
+ publishPrekeysToIdentity,
};

File Metadata

Mime Type
text/plain
Expires
Tue, Jan 13, 10:44 PM (5 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5929225
Default Alt Text
D9427.1768344266.diff (3 KB)

Event Timeline