Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246813
D5311.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
D5311.diff
View Options
diff --git a/keyserver/src/updaters/viewer-acknowledgment-updater.js b/keyserver/src/updaters/viewer-acknowledgment-updater.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/updaters/viewer-acknowledgment-updater.js
@@ -0,0 +1,23 @@
+// @flow
+
+import type { PolicyType } from 'lib/facts/policies.js';
+
+import { dbQuery, SQL } from '../database/database.js';
+import type { Viewer } from '../session/viewer.js';
+
+async function viewerAcknowledgmentUpdater(viewer: Viewer, policy: PolicyType) {
+ if (!viewer.loggedIn) {
+ return;
+ }
+
+ const time = Date.now();
+ await dbQuery(SQL`
+ INSERT INTO policy_acknowledgments (user, policy, date, confirmed)
+ VALUES (${viewer.data.id}, ${policy}, ${time}, 1)
+ ON DUPLICATE KEY UPDATE
+ date = IF (confirmed = 1, date, ${time}),
+ confirmed = 1
+ `);
+}
+
+export { viewerAcknowledgmentUpdater };
diff --git a/lib/facts/policies.js b/lib/facts/policies.js
--- a/lib/facts/policies.js
+++ b/lib/facts/policies.js
@@ -7,3 +7,5 @@
});
export const policies: $ReadOnlyArray<string> = values(policyTypes);
+
+export type PolicyType = $Values<typeof policyTypes>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 1:55 AM (21 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2496070
Default Alt Text
D5311.diff (1 KB)
Attached To
Mode
D5311: [keyserver] add logic to update acknowledgment table
Attached
Detach File
Event Timeline
Log In to Comment