Page MenuHomePhabricator

D8948.id.diff
No OneTemporary

D8948.id.diff

diff --git a/keyserver/src/shared/state-sync/current-user-state-sync-spec.js b/keyserver/src/shared/state-sync/current-user-state-sync-spec.js
--- a/keyserver/src/shared/state-sync/current-user-state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/current-user-state-sync-spec.js
@@ -15,4 +15,5 @@
fetch(viewer: Viewer) {
return fetchCurrentUserInfo(viewer);
},
+ hashKey: 'currentUserInfo',
});
diff --git a/keyserver/src/shared/state-sync/entries-state-sync-spec.js b/keyserver/src/shared/state-sync/entries-state-sync-spec.js
--- a/keyserver/src/shared/state-sync/entries-state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/entries-state-sync-spec.js
@@ -23,5 +23,6 @@
const entriesResult = await fetchEntryInfos(viewer, query);
return serverEntryInfosObject(entriesResult.rawEntryInfos);
},
+ hashKey: 'entryInfos',
},
);
diff --git a/keyserver/src/shared/state-sync/state-sync-spec.js b/keyserver/src/shared/state-sync/state-sync-spec.js
--- a/keyserver/src/shared/state-sync/state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/state-sync-spec.js
@@ -10,4 +10,5 @@
calendarQuery: $ReadOnlyArray<CalendarQuery>,
ids?: $ReadOnlySet<string>,
) => Promise<Infos>,
+ +hashKey: string,
};
diff --git a/keyserver/src/shared/state-sync/threads-state-sync-spec.js b/keyserver/src/shared/state-sync/threads-state-sync-spec.js
--- a/keyserver/src/shared/state-sync/threads-state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/threads-state-sync-spec.js
@@ -20,4 +20,5 @@
const result = await fetchThreadInfos(viewer, filter);
return result.threadInfos;
},
+ hashKey: 'threadInfos',
});
diff --git a/keyserver/src/shared/state-sync/users-state-sync-spec.js b/keyserver/src/shared/state-sync/users-state-sync-spec.js
--- a/keyserver/src/shared/state-sync/users-state-sync-spec.js
+++ b/keyserver/src/shared/state-sync/users-state-sync-spec.js
@@ -19,4 +19,5 @@
return fetchKnownUserInfos(viewer);
},
+ hashKey: 'userInfos',
});
diff --git a/keyserver/src/socket/session-utils.js b/keyserver/src/socket/session-utils.js
--- a/keyserver/src/socket/session-utils.js
+++ b/keyserver/src/socket/session-utils.js
@@ -26,7 +26,7 @@
} from 'lib/types/request-types.js';
import { sessionCheckFrequency } from 'lib/types/session-types.js';
import { signedIdentityKeysBlobValidator } from 'lib/utils/crypto-utils.js';
-import { hash } from 'lib/utils/objects.js';
+import { hash, values } from 'lib/utils/objects.js';
import { promiseAll } from 'lib/utils/promises.js';
import {
tShape,
@@ -384,19 +384,16 @@
if (status.status === 'state_validated') {
return { sessionUpdate: { lastValidated: Date.now() } };
} else if (status.status === 'state_check') {
- const promises = {
- threadsResult: serverStateSyncSpecs.threads.fetch(viewer, query),
- entriesResult: serverStateSyncSpecs.entries.fetch(viewer, query),
- currentUserInfo: serverStateSyncSpecs.currentUser.fetch(viewer, query),
- userInfosResult: serverStateSyncSpecs.users.fetch(viewer, query),
- };
- const fetchedData = await promiseAll(promises);
- const hashesToCheck = {
- threadInfos: hash(fetchedData.threadsResult),
- entryInfos: hash(fetchedData.entriesResult),
- currentUserInfo: hash(fetchedData.currentUserInfo),
- userInfos: hash(fetchedData.userInfosResult),
- };
+ const promises = Object.fromEntries(
+ values(serverStateSyncSpecs).map(spec => [
+ spec.hashKey,
+ (async () => {
+ const data = await spec.fetch(viewer, query);
+ return hash(data);
+ })(),
+ ]),
+ );
+ const hashesToCheck = await promiseAll(promises);
const checkStateRequest = {
type: serverRequestTypes.CHECK_STATE,
hashesToCheck,

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 10:44 PM (19 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2696957
Default Alt Text
D8948.id.diff (3 KB)

Event Timeline