Page MenuHomePhabricator

D11362.id38215.diff
No OneTemporary

D11362.id38215.diff

diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js
--- a/web/grpc/identity-service-client-wrapper.js
+++ b/web/grpc/identity-service-client-wrapper.js
@@ -533,29 +533,60 @@
notifOneTimeKeys,
} = uploadData;
- const contentOneTimeKeysArray = [...contentOneTimeKeys];
- const notifOneTimeKeysArray = [...notifOneTimeKeys];
+ const identityKeyInfo = createIdentityKeyInfo(
+ keyPayload,
+ keyPayloadSignature,
+ );
+
+ const contentPrekeyUpload = createPrekey(
+ contentPrekey,
+ contentPrekeySignature,
+ );
+
+ const notifPrekeyUpload = createPrekey(notifPrekey, notifPrekeySignature);
+
+ const deviceKeyUpload = createDeviceKeyUpload(
+ identityKeyInfo,
+ contentPrekeyUpload,
+ notifPrekeyUpload,
+ contentOneTimeKeys,
+ notifOneTimeKeys,
+ );
+ return deviceKeyUpload;
+}
+
+function createIdentityKeyInfo(
+ keyPayload: string,
+ keyPayloadSignature: string,
+): IdentityKeyInfo {
const identityKeyInfo = new IdentityKeyInfo();
identityKeyInfo.setPayload(keyPayload);
identityKeyInfo.setPayloadSignature(keyPayloadSignature);
+ return identityKeyInfo;
+}
- const contentPrekeyUpload = new Prekey();
- contentPrekeyUpload.setPrekey(contentPrekey);
- contentPrekeyUpload.setPrekeySignature(contentPrekeySignature);
-
- const notifPrekeyUpload = new Prekey();
- notifPrekeyUpload.setPrekey(notifPrekey);
- notifPrekeyUpload.setPrekeySignature(notifPrekeySignature);
+function createPrekey(prekey: string, prekeySignature: string): Prekey {
+ const prekeyUpload = new Prekey();
+ prekeyUpload.setPrekey(prekey);
+ prekeyUpload.setPrekeySignature(prekeySignature);
+ return prekeyUpload;
+}
+function createDeviceKeyUpload(
+ identityKeyInfo: IdentityKeyInfo,
+ contentPrekeyUpload: Prekey,
+ notifPrekeyUpload: Prekey,
+ contentOneTimeKeys: $ReadOnlyArray<string> = [],
+ notifOneTimeKeys: $ReadOnlyArray<string> = [],
+): DeviceKeyUpload {
const deviceKeyUpload = new DeviceKeyUpload();
deviceKeyUpload.setDeviceKeyInfo(identityKeyInfo);
deviceKeyUpload.setContentUpload(contentPrekeyUpload);
deviceKeyUpload.setNotifUpload(notifPrekeyUpload);
- deviceKeyUpload.setOneTimeContentPrekeysList(contentOneTimeKeysArray);
- deviceKeyUpload.setOneTimeNotifPrekeysList(notifOneTimeKeysArray);
+ deviceKeyUpload.setOneTimeContentPrekeysList([...contentOneTimeKeys]);
+ deviceKeyUpload.setOneTimeNotifPrekeysList([...notifOneTimeKeys]);
deviceKeyUpload.setDeviceType(identityDeviceTypes.WEB);
-
return deviceKeyUpload;
}

File Metadata

Mime Type
text/plain
Expires
Fri, Jan 10, 7:04 PM (13 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2853849
Default Alt Text
D11362.id38215.diff (2 KB)

Event Timeline