Skip to content
Snippets Groups Projects
Unverified Commit 342c5edf authored by Mathieu Othacehe's avatar Mathieu Othacehe
Browse files

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.
parent a0e12c38
No related branches found
No related tags found
No related merge requests found
...@@ -17,18 +17,15 @@ ...@@ -17,18 +17,15 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (cuirass mastodon) (define-module (cuirass mastodon)
#:use-module (cuirass parameters)
#:use-module (mastodon) #:use-module (mastodon)
#:use-module (mastodon types) #:use-module (mastodon types)
#:export (send-status)) #:export (send-status))
(define* (send-status text (define (send-status text)
#:key
instance-name
instance-url
instance-token)
"Send a new status with the given TEXT to the instance named INSTANCE-NAME "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." at the INSTANCE-URL address. Use the given INSTANCE-TOKEN to authenticate."
(let ((instance (make-mastodon instance-name (let ((instance (make-mastodon (%mastodon-instance-name)
instance-url (%mastodon-instance-url)
instance-token))) (%mastodon-instance-token))))
(new-status instance #:status text))) (new-status instance #:status text)))
...@@ -113,14 +113,8 @@ the detailed information about this build here: ~a." ...@@ -113,14 +113,8 @@ the detailed information about this build here: ~a."
(define (notification-mastodon notification) (define (notification-mastodon notification)
"Send a new status for the given NOTIFICATION." "Send a new status for the given NOTIFICATION."
(let ((name (assq-ref notification #:instance-name)) (let ((text (notification-text notification)))
(url (assq-ref notification #:instance-url)) (send-status text)))
(token (assq-ref notification #:instance-token))
(text (notification-text notification)))
(send-status text
#:instance-name name
#:instance-url url
#:instance-token token)))
(define* (send-notifications notifications #:key build) (define* (send-notifications notifications #:key build)
"Send the notifications in NOTIFICATIONS list, regarding the given BUILD." "Send the notifications in NOTIFICATIONS list, regarding the given BUILD."
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
#:export (%cuirass-url #:export (%cuirass-url
%zabbix-url %zabbix-url
%zabbix-user %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 ;; The URL of the Cuirass web server. This is useful to send absolute links
;; within notifications. ;; within notifications.
...@@ -39,3 +42,15 @@ ...@@ -39,3 +42,15 @@
;; The password for Zabbix API authentication. ;; The password for Zabbix API authentication.
(define %zabbix-password (define %zabbix-password
(make-parameter "zabbix")) (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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment