summaryrefslogtreecommitdiff
path: root/jakob/dynamic/capabilities
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2024-07-19 19:23:09 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2024-07-21 14:08:34 -0400
commit9c7651e85975572a7c2afc30106e25ff4be9e2ef (patch)
tree43e03535a98b634e2a16cfb34ea68bdfcfa1fc87 /jakob/dynamic/capabilities
parent6b6bd281673554ee44707293535edfad5a9919c1 (diff)
[dynamic] Implement Gotify notifications for comments and RSVPs
Diffstat (limited to 'jakob/dynamic/capabilities')
-rw-r--r--jakob/dynamic/capabilities/comment-form.scm4
-rw-r--r--jakob/dynamic/capabilities/comments.scm11
-rw-r--r--jakob/dynamic/capabilities/rsvp.scm7
3 files changed, 16 insertions, 6 deletions
diff --git a/jakob/dynamic/capabilities/comment-form.scm b/jakob/dynamic/capabilities/comment-form.scm
index f7d0491..12a5f57 100644
--- a/jakob/dynamic/capabilities/comment-form.scm
+++ b/jakob/dynamic/capabilities/comment-form.scm
@@ -63,9 +63,7 @@
""))))
(input (@ (type "text") (id "captcha") (name "captcha") (size 24))))
(button (@ (id "pow-trigger") (hidden #t))
- "Too hard? (Or unable to see the challenge?)"
- (br)
- "Click here for an alternative captcha.")
+ "Too hard? (Or unable to see the challenge?) Click here.")
(input (@ (autocomplete "off") (type "text") (id "captcha-id") (name "captcha-id") (hidden #t) (value ,captcha-id)))
(input (@ (autocomplete "off") (type "text") (id "captcha-alt") (name "captcha-alt") (hidden #t)))
(input (@ (autocomplete "off") (type "text") (id "captcha-alt-id") (name "captcha-alt-id") (hidden #t)))
diff --git a/jakob/dynamic/capabilities/comments.scm b/jakob/dynamic/capabilities/comments.scm
index ee2a52d..d2e34dc 100644
--- a/jakob/dynamic/capabilities/comments.scm
+++ b/jakob/dynamic/capabilities/comments.scm
@@ -20,6 +20,8 @@
#:use-module (jakob dynamic captcha)
#:use-module (jakob dynamic config)
#:use-module (jakob dynamic errors)
+ #:use-module (jakob dynamic logging)
+ #:use-module (jakob dynamic notify)
#:use-module (jakob dynamic util)
#:use-module (json)
#:use-module (squee)
@@ -173,8 +175,15 @@ This is a wrapper around `get-comments-by-slug'."
(assoc-value form-data "captcha")
(string->number (assoc-value form-data "captcha-id")))
(panic "captcha incorrect")))
+ (log-append! 'debug (format #f "Form data: ~a" form-data))
+ (notify 5
+ (if (assoc "subject" form-data)
+ (format #f "New Comment: ~a" (assoc-value form-data "subject"))
+ "New Comment")
+ (format #f "~a: ~a"
+ (assoc-value form-data "name")
+ (assoc-value form-data "comment")))
(insert-comment form-data)))
-
(define (add-reaction reactions reaction)
diff --git a/jakob/dynamic/capabilities/rsvp.scm b/jakob/dynamic/capabilities/rsvp.scm
index 25f13b8..4a7ada2 100644
--- a/jakob/dynamic/capabilities/rsvp.scm
+++ b/jakob/dynamic/capabilities/rsvp.scm
@@ -21,6 +21,7 @@
#:use-module (ice-9 match)
#:use-module (jakob dynamic config)
#:use-module (jakob dynamic errors)
+ #:use-module (jakob dynamic notify)
#:use-module (jakob dynamic util)
#:use-module (jakob theme)
#:use-module (json)
@@ -39,7 +40,7 @@
(define %vanity-length (make-parameter 12))
;; Path where event header images are stored.
-(define %event-image-path-fmt (make-parameter "/opt/jakob-dynamic/event-images/~a.png"))
+(define %event-image-path-fmt (make-parameter "/opt/jakob-dynamic/event-images/~a.webp"))
;; Global handle to the RSVP database.
(define conn (connect-to-postgres-paramstring (paramstring-for-dbname "jakob_rsvp")))
@@ -138,6 +139,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(rsvp-create-email params)
(rsvp-create-attending params)
(rsvp-create-guests params)))
+ (notify 5 (format #f "~a RSVP'd to an event!" (rsvp-create-name params)) "")
(values '((content-type . (text/html)))
(sxml->html-string
(theme #:title "Thanks for RSVPing!"
@@ -186,6 +188,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(rsvp-update-email params)
(rsvp-update-attending params)
(rsvp-update-guests params)))
+ (notify 5 (format #f "~a updated their RSVP!" (rsvp-update-name params)) "")
(values '((content-type . (text/html)))
(sxml->html-string
(theme #:title "Thanks for RSVPing!"
@@ -225,7 +228,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
`(div (@ (id "rsvp"))
(div (@ (id "event-info"))
(h1 ,title)
- (img (@ (src ,(format #f "data:image/png;base64, ~a" (get-event-image (car invitation))))
+ (img (@ (src ,(format #f "data:image/webp;base64, ~a" (get-event-image (car invitation))))
(style "float: right; margin: 16px;")))
(p "Where: " ,location)
(p "When: " ,date)