Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3247096
D6091.id20751.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6091.id20751.diff
View Options
diff --git a/keyserver/src/fetchers/policy-acknowledgment-fetchers.js b/keyserver/src/fetchers/policy-acknowledgment-fetchers.js
--- a/keyserver/src/fetchers/policy-acknowledgment-fetchers.js
+++ b/keyserver/src/fetchers/policy-acknowledgment-fetchers.js
@@ -20,4 +20,20 @@
return data;
}
-export { fetchPolicyAcknowledgments };
+async function fetchNotAcknowledgedPolicies(
+ viewer: Viewer,
+ policies: $ReadOnlyArray<PolicyType>,
+): Promise<$ReadOnlyArray<PolicyType>> {
+ const viewerAcknowledgments = await fetchPolicyAcknowledgments(
+ viewer,
+ policies,
+ );
+ return policies.filter(policy => {
+ const policyAcknowledgment = viewerAcknowledgments.find(
+ viewerAcknowledgment => viewerAcknowledgment.policy === policy,
+ );
+ return !policyAcknowledgment?.confirmed;
+ });
+}
+
+export { fetchPolicyAcknowledgments, fetchNotAcknowledgedPolicies };
diff --git a/keyserver/src/utils/validation-utils.js b/keyserver/src/utils/validation-utils.js
--- a/keyserver/src/utils/validation-utils.js
+++ b/keyserver/src/utils/validation-utils.js
@@ -10,7 +10,7 @@
tPlatformDetails,
} from 'lib/utils/validation-utils';
-import { fetchPolicyAcknowledgments } from '../fetchers/policy-acknowledgment-fetchers.js';
+import { fetchNotAcknowledgedPolicies } from '../fetchers/policy-acknowledgment-fetchers.js';
import { verifyClientSupported } from '../session/version';
import type { Viewer } from '../session/viewer';
@@ -167,16 +167,10 @@
return;
}
- const viewerAcknowledgments = await fetchPolicyAcknowledgments(
+ const notAcknowledgedPolicies = await fetchNotAcknowledgedPolicies(
viewer,
policies,
);
- const notAcknowledgedPolicies = policies.filter(policy => {
- const policyAcknowledgment = viewerAcknowledgments.find(
- viewerAcknowledgment => viewerAcknowledgment.policy === policy,
- );
- return !policyAcknowledgment?.confirmed;
- });
if (notAcknowledgedPolicies.length) {
throw new ServerError('policies_not_accepted', {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 3:29 AM (21 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496259
Default Alt Text
D6091.id20751.diff (1 KB)
Attached To
Mode
D6091: [keyserver] move logic to fetch not acknowledged policies to separate function
Attached
Detach File
Event Timeline
Log In to Comment