;;; Copyright © 2019 - 2024 Jakob L. Kreuze ;;; ;;; 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 ;;; . (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))