Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3293388
D11384.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11384.diff
View Options
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
@@ -6,6 +6,7 @@
Utility as OlmUtility,
Session as OlmSession,
} from '@commapp/olm';
+import invariant from 'invariant';
import { getRustAPI } from 'rust-node-addon';
import uuid from 'uuid';
@@ -111,32 +112,42 @@
throw new ServerError('missing_identity_info');
}
- await fetchCallUpdateOlmAccount('content', (contentAccount: OlmAccount) => {
- contentAccount.generate_one_time_keys(numberOfKeys);
- const contentOneTimeKeys = getOneTimeKeyValuesFromBlob(
- contentAccount.one_time_keys(),
- );
+ let contentOneTimeKeys: ?$ReadOnlyArray<string>;
+ let notifOneTimeKeys: ?$ReadOnlyArray<string>;
+
+ await Promise.all([
+ fetchCallUpdateOlmAccount('content', (contentAccount: OlmAccount) => {
+ contentAccount.generate_one_time_keys(numberOfKeys);
+ contentOneTimeKeys = getOneTimeKeyValuesFromBlob(
+ contentAccount.one_time_keys(),
+ );
+ contentAccount.mark_keys_as_published();
+ }),
+ fetchCallUpdateOlmAccount('notifications', (notifAccount: OlmAccount) => {
+ notifAccount.generate_one_time_keys(numberOfKeys);
+ notifOneTimeKeys = getOneTimeKeyValuesFromBlob(
+ notifAccount.one_time_keys(),
+ );
+ notifAccount.mark_keys_as_published();
+ }),
+ ]);
- return fetchCallUpdateOlmAccount(
- 'notifications',
- async (notifAccount: OlmAccount) => {
- notifAccount.generate_one_time_keys(numberOfKeys);
- const notifOneTimeKeys = getOneTimeKeyValuesFromBlob(
- notifAccount.one_time_keys(),
- );
- await rustAPI.uploadOneTimeKeys(
- identityInfo.userId,
- deviceID,
- identityInfo.accessToken,
- contentOneTimeKeys,
- notifOneTimeKeys,
- );
-
- notifAccount.mark_keys_as_published();
- contentAccount.mark_keys_as_published();
- },
- );
- });
+ invariant(
+ contentOneTimeKeys,
+ 'content one-time keys not set after fetchCallUpdateOlmAccount',
+ );
+ invariant(
+ notifOneTimeKeys,
+ 'notif one-time keys not set after fetchCallUpdateOlmAccount',
+ );
+
+ await rustAPI.uploadOneTimeKeys(
+ identityInfo.userId,
+ deviceID,
+ identityInfo.accessToken,
+ contentOneTimeKeys,
+ notifOneTimeKeys,
+ );
}
async function getContentSigningKey(): Promise<string> {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 17, 5:10 PM (19 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2530669
Default Alt Text
D11384.diff (2 KB)
Attached To
Mode
D11384: [keyserver] Fix olm_session_creation_failure bug due to fetchOlmUpdateAccount retry
Attached
Detach File
Event Timeline
Log In to Comment