From 264925b319957190037554bf49ce2c55152437b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Mon, 17 Apr 2023 20:24:33 +0200 Subject: [PATCH] Split out sending and printing of email data structure. --- src/notifications.scm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/notifications.scm b/src/notifications.scm index bbc8c68..88c9f3f 100644 --- a/src/notifications.scm +++ b/src/notifications.scm @@ -79,7 +79,7 @@ (body . ,(reminder-email-body mr))))) ;; Prints email to the console - (define (print-reminder-email em) + (define (print-notification-email em) (print "### From: " (ldict-ref em 'from "-")) (print "### To: " (ldict-ref em 'to)) (print "### Subject: " (ldict-ref em 'subject)) @@ -88,18 +88,22 @@ (print (car lines)) (loop (cdr lines))))) + ;; Sends notification email - the dictionary representation + (define (send-notification-email em) + (print "Sending " (ldict-ref em 'subject) " originally to " (ldict-ref em 'to)) + (send-mail (ldict-ref em 'body) + #:from (*email-from*) + #:to (ldict-ref em 'to) + #:subject (ldict-ref em 'subject))) + ;; Creates and prints reminder email for given member record (define (make+print-reminder-email mr) - (print-reminder-email + (print-notification-email (make-reminder-email mr))) ;; Actually send emails (define (make+send-reminder-email mr) (let ((em (make-reminder-email mr))) - (print "Sending " (ldict-ref em 'subject) " originally to " (ldict-ref em 'to)) - (send-mail (ldict-ref em 'body) - #:from (*email-from*) - #:to "joe@joe.cz" - #:subject (ldict-ref em 'subject)))) + (send-notification-email em))) )