aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2022-05-08 06:19:10 +0200
committerTeddy Wing2022-05-08 06:19:10 +0200
commit27a205d81647c9df3c6c04f36062b87987d5ae99 (patch)
tree429152d5559ec9b398bca32f553dee14e8e44f0b
parent22461379250147870550d4d9cd43dc67f65892a9 (diff)
downloadwajir-27a205d81647c9df3c6c04f36062b87987d5ae99.tar.bz2
Format 'issue created' email
Include a selection of metadata values in the email. I needed to pass `config` to `deliver-email` in order to be able to build a URL to the ticket based on the `endpoint` field. Also needed to make the field list a vector instead of a list, otherwise 'jzon' interpreted it as being a plist and serialized it to a JSON object.
-rw-r--r--src/email.lisp29
-rw-r--r--src/main.lisp17
2 files changed, 32 insertions, 14 deletions
diff --git a/src/email.lisp b/src/email.lisp
index c877eda..9e5929c 100644
--- a/src/email.lisp
+++ b/src/email.lisp
@@ -1,12 +1,12 @@
(in-package :wajir)
-(defun deliver-email (recipient issue)
+(defun deliver-email (config issue)
(cl-smtp:write-rfc8822-message
*standard-output*
(format nil "wajir@~A" (uiop:hostname))
- `(,recipient)
+ `(,(email-to config))
(format-subject issue)
- (format-description issue)))
+ (format-body issue (endpoint config))))
(defun format-subject (issue)
(format nil
@@ -15,6 +15,23 @@
(gethash "summary"
(gethash "fields" issue))))
-(defun format-description (issue)
- (gethash "description"
- (gethash "fields" issue)))
+(defun format-body (issue endpoint)
+ (let ((fields (gethash "fields" issue)))
+ (format nil
+ "~A created ~A:~%~%Summary: ~A~%Key: ~A~%URL: ~A~%Project: ~A~%Issue Type: ~A~%Reporter: ~A~%~%~%~A"
+ (gethash "displayName"
+ (gethash "creator" fields))
+ (gethash "key" issue)
+ (gethash "summary" fields)
+ (gethash "key" issue)
+ (format nil
+ "https://~A/browse/~A"
+ endpoint
+ (gethash "key" issue))
+ (gethash "name"
+ (gethash "project" fields))
+ (gethash "name"
+ (gethash "issuetype" fields))
+ (gethash "displayName"
+ (gethash "reporter" fields))
+ (gethash "description" fields))))
diff --git a/src/main.lisp b/src/main.lisp
index e48cf34..7c0f368 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -66,13 +66,14 @@
:content
(jzon:stringify
`((:jql . ,jql)
- (:fields . ("id"
- "key"
- "project"
- "summary"
- "description"
- "issuetype"
- "reporter"))
+ (:fields . #("id"
+ "key"
+ "project"
+ "summary"
+ "description"
+ "issuetype"
+ "creator"
+ "reporter"))
(:|startAt| . ,start-at)))
:headers `((:content-type . "application/json")
(:authorization
@@ -83,4 +84,4 @@
;; 2. Send email
(format t "Watching issue ~A~%" (gethash "key" issue))
- (deliver-email (email-to config) issue))
+ (deliver-email config issue))