Page MenuHomePhabricator

D11384.id.diff
No OneTemporary

D11384.id.diff

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

Mime Type
text/plain
Expires
Sun, Nov 17, 5:10 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2530669
Default Alt Text
D11384.id.diff (2 KB)

Event Timeline