From 243c4bc8093992164a12892b29172b3a5127c820 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 8 May 2022 13:29:51 +0200 Subject: Call the Jira API to watch unwatched issues --- src/main.lisp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index d700182..3b6da43 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -46,7 +46,10 @@ ; across (gethash "issues" response) ; do (watch-issue config issue)) (let ((issue (aref (gethash "issues" response) 0))) - (watch-issue config issue) + (watch-issue + config + issue + :basic-auth-token basic-auth-token) (return)) @@ -79,10 +82,24 @@ (:authorization . ,(format nil "Basic ~A" basic-auth-token)))))) -(defun watch-issue (config issue) +(defun watch-issue (config issue &key basic-auth-token) ;; 1. Watch issue in Jira ;; 2. Send email (format t "Watching issue ~A~%" (gethash "key" issue)) + (add-watcher + (endpoint config) + issue + :basic-auth-token basic-auth-token) + (if (sendmail config) (deliver-email config issue))) + +(defun add-watcher (endpoint issue &key basic-auth-token) + "Add the authenticated user as a watcher to issue." + (dex:post + (format nil + "https://~A/rest/api/2/issue/~A/watchers" + endpoint + (gethash "id" issue)) + :headers `((:authorization . ,(format nil "Basic ~A" basic-auth-token))))) -- cgit v1.2.3