about summary refs log tree commit diff
path: root/web/panettone/src/model.lisp
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2021-04-03T18·27-0400
committerglittershark <grfn@gws.fyi>2021-04-04T14·17+0000
commit3ec15ec9f9b4f010f32630cc3cef19120c90ed28 (patch)
tree042e2d533d0c7d45f5ecdb001128d5b64b52f06c /web/panettone/src/model.lisp
parent8d3ab61e7c136610ae1dc002226559e8c6b21fcb (diff)
feat(panettone): Add a settings page r/2428
Add a user settings page, with a single checkbox that allows disabling
receiving all email notifications.

Change-Id: Ibef2a497cd59f93b695ff8b9cd36047e514e00c2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2806
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'web/panettone/src/model.lisp')
-rw-r--r--web/panettone/src/model.lisp18
1 files changed, 18 insertions, 0 deletions
diff --git a/web/panettone/src/model.lisp b/web/panettone/src/model.lisp
index 648b9a5677a1..d7d1af924c29 100644
--- a/web/panettone/src/model.lisp
+++ b/web/panettone/src/model.lisp
@@ -55,6 +55,24 @@ database connection."
      (:select '* :from 'user-settings :where (:= 'user-dn dn))))
    (insert-dao (make-instance 'user-settings :user-dn dn))))
 
+(defun update-user-settings (settings &rest attrs)
+  "Update the fields of the settings for USER with the given ATTRS, which is a
+  plist of slot and value"
+  (check-type settings user-settings)
+  (when-let ((set-fields
+              (iter
+                (for slot in '(enable-email-notifications))
+                (for new-value = (getf attrs slot))
+                (appending
+                 (progn
+                   (setf (slot-value settings slot) new-value)
+                   (list slot new-value))))))
+    (execute
+     (sql-compile
+      `(:update user-settings
+        :set ,@set-fields
+        :where (:= user-dn ,(user-dn settings)))))))
+
 
 (define-constant +issue-statuses+ '(:open :closed)
   :test #'equal)