Page MenuHomePhabricator

D5822.diff
No OneTemporary

D5822.diff

diff --git a/keyserver/src/fetchers/policy-acknowledgment-fetchers.js b/keyserver/src/fetchers/policy-acknowledgment-fetchers.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/fetchers/policy-acknowledgment-fetchers.js
@@ -0,0 +1,23 @@
+// @flow
+
+import type { PolicyType } from 'lib/facts/policies.js';
+import { type UserPolicyConfirmationType } from 'lib/types/policy-types.js';
+
+import { dbQuery, SQL } from '../database/database.js';
+import { Viewer } from '../session/viewer.js';
+
+async function fetchPolicyAcknowledgments(
+ viewer: Viewer,
+ policies: $ReadOnlyArray<PolicyType>,
+): Promise<$ReadOnlyArray<UserPolicyConfirmationType>> {
+ const query = SQL`
+ SELECT policy, confirmed
+ FROM policy_acknowledgments
+ WHERE user=${viewer.id}
+ AND policy IN (${policies})
+ `;
+ const [data] = await dbQuery(query);
+ return data;
+}
+
+export { fetchPolicyAcknowledgments };
diff --git a/lib/types/policy-types.js b/lib/types/policy-types.js
new file mode 100644
--- /dev/null
+++ b/lib/types/policy-types.js
@@ -0,0 +1,8 @@
+// @flow
+
+import type { PolicyType } from '../facts/policies.js';
+
+export type UserPolicyConfirmationType = {
+ +policy: PolicyType,
+ +confirmed: boolean,
+};

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 2:04 PM (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2677628
Default Alt Text
D5822.diff (1 KB)

Event Timeline