aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-05-08 13:29:51 +0200
committerTeddy Wing2022-05-08 13:29:51 +0200
commit243c4bc8093992164a12892b29172b3a5127c820 (patch)
tree1fc898e163e2d8ea11b9667953c977329630053f
parent8f111e2caf045a3385fe0d069c3b94d1e9b8cf20 (diff)
downloadwajir-243c4bc8093992164a12892b29172b3a5127c820.tar.bz2
Call the Jira API to watch unwatched issues
-rw-r--r--src/main.lisp21
1 files 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)))))