summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--jakob/dynamic/notify.scm31
4 files changed, 47 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)
diff --git a/jakob/dynamic/notify.scm b/jakob/dynamic/notify.scm
new file mode 100644
index 0000000..ff8763c
--- /dev/null
+++ b/jakob/dynamic/notify.scm
@@ -0,0 +1,31 @@
+;;; Copyright © 2019 - 2024 Jakob L. Kreuze <zerodaysfordays@sdf.org>
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (jakob dynamic notify)
+ #:use-module (json)
+ #:use-module (web client)
+ #:export (notify))
+
+(define gotify-base-url (getenv "GOTIFY_URL"))
+(define gotify-token (getenv "GOTIFY_TOKEN"))
+
+(define (notify priority title message)
+ "Push a notification with PRIORITY, TITLE, and MESSAGE to Gotify"
+ (define url
+ (format #f "https://~a/message?token=~a" gotify-base-url gotify-token))
+ (define body
+ (scm->json-string `((priority . ,priority) (title . ,title) (message . ,message))))
+ (http-post url #:headers '((content-type . (application/json))) #:body body))