aboutsummaryrefslogtreecommitdiffstats
path: root/src/email.lisp
diff options
context:
space:
mode:
authorTeddy Wing2022-05-08 06:19:10 +0200
committerTeddy Wing2022-05-08 06:19:10 +0200
commit27a205d81647c9df3c6c04f36062b87987d5ae99 (patch)
tree429152d5559ec9b398bca32f553dee14e8e44f0b /src/email.lisp
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.
Diffstat (limited to 'src/email.lisp')
-rw-r--r--src/email.lisp29
1 files changed, 23 insertions, 6 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))))