Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3519635
D8948.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D8948.id.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D8948: [keyserver] Generalize state_check status handling using specs
Attached
Detach File
Event Timeline
Log In to Comment