Page MenuHomePhabricator

D6091.id20751.diff
No OneTemporary

D6091.id20751.diff

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

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)

Event Timeline