From 342c5edfe8c372f916aa82a486943086158f4e1a Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe <othacehe@gnu.org> Date: Mon, 22 Feb 2021 10:15:58 +0100 Subject: [PATCH] Use parameters for the Mastodon crendentials. * src/cuirass/parameters.scm (%mastodon-instance-name, %mastodon-instance-url, %mastodon-instance-token): New variables. * src/cuirass/mastodon.scm (send-status): Remove "instance-name", "instance-url" and "instance-token" parameters. * src/cuirass/notification (notification-mastodon): Adapt accordingly. --- src/cuirass/mastodon.scm | 13 +++++-------- src/cuirass/notification.scm | 10 ++-------- src/cuirass/parameters.scm | 17 ++++++++++++++++- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/cuirass/mastodon.scm b/src/cuirass/mastodon.scm index 1cfa6b43..be74bc8e 100644 --- a/src/cuirass/mastodon.scm +++ b/src/cuirass/mastodon.scm @@ -17,18 +17,15 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (cuirass mastodon) + #:use-module (cuirass parameters) #:use-module (mastodon) #:use-module (mastodon types) #:export (send-status)) -(define* (send-status text - #:key - instance-name - instance-url - instance-token) +(define (send-status text) "Send a new status with the given TEXT to the instance named INSTANCE-NAME at the INSTANCE-URL address. Use the given INSTANCE-TOKEN to authenticate." - (let ((instance (make-mastodon instance-name - instance-url - instance-token))) + (let ((instance (make-mastodon (%mastodon-instance-name) + (%mastodon-instance-url) + (%mastodon-instance-token)))) (new-status instance #:status text))) diff --git a/src/cuirass/notification.scm b/src/cuirass/notification.scm index 262b90dc..fc983cb1 100644 --- a/src/cuirass/notification.scm +++ b/src/cuirass/notification.scm @@ -113,14 +113,8 @@ the detailed information about this build here: ~a." (define (notification-mastodon notification) "Send a new status for the given NOTIFICATION." - (let ((name (assq-ref notification #:instance-name)) - (url (assq-ref notification #:instance-url)) - (token (assq-ref notification #:instance-token)) - (text (notification-text notification))) - (send-status text - #:instance-name name - #:instance-url url - #:instance-token token))) + (let ((text (notification-text notification))) + (send-status text))) (define* (send-notifications notifications #:key build) "Send the notifications in NOTIFICATIONS list, regarding the given BUILD." diff --git a/src/cuirass/parameters.scm b/src/cuirass/parameters.scm index e9be8a37..fb580bf7 100644 --- a/src/cuirass/parameters.scm +++ b/src/cuirass/parameters.scm @@ -20,7 +20,10 @@ #:export (%cuirass-url %zabbix-url %zabbix-user - %zabbix-password)) + %zabbix-password + %mastodon-instance-name + %mastodon-instance-url + %mastodon-instance-token)) ;; The URL of the Cuirass web server. This is useful to send absolute links ;; within notifications. @@ -39,3 +42,15 @@ ;; The password for Zabbix API authentication. (define %zabbix-password (make-parameter "zabbix")) + +;; The name of the Mastodon instance used to send build notifications. +(define %mastodon-instance-name + (make-parameter #f)) + +;; The URL of the Mastodon instance. +(define %mastodon-instance-url + (make-parameter #f)) + +;; The token used to authenticate on the Mastodon instance. +(define %mastodon-instance-token + (make-parameter #f)) -- GitLab