diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-07-19 19:23:09 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2024-07-21 14:08:34 -0400 |
| commit | 9c7651e85975572a7c2afc30106e25ff4be9e2ef (patch) | |
| tree | 43e03535a98b634e2a16cfb34ea68bdfcfa1fc87 /jakob/dynamic/notify.scm | |
| parent | 6b6bd281673554ee44707293535edfad5a9919c1 (diff) | |
[dynamic] Implement Gotify notifications for comments and RSVPs
Diffstat (limited to 'jakob/dynamic/notify.scm')
| -rw-r--r-- | jakob/dynamic/notify.scm | 31 |
1 files changed, 31 insertions, 0 deletions
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)) |