From 863afdc5b4dd33854887092ad86b6ee40dd083c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Mon, 17 Apr 2023 20:37:47 +0200 Subject: [PATCH] Create skeleton of summary email infrastructure. --- src/notifications.scm | 48 +++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/notifications.scm b/src/notifications.scm index 88c9f3f..d599d2a 100644 --- a/src/notifications.scm +++ b/src/notifications.scm @@ -43,6 +43,27 @@ brmember-format configuration) + ;; TODO - later move to configuration + (define *summary-mailto* "rada@brmlab.cz") + + ;; Prints email to the console + (define (print-notification-email em) + (print "### From: " (ldict-ref em 'from "-")) + (print "### To: " (ldict-ref em 'to)) + (print "### Subject: " (ldict-ref em 'subject)) + (let loop ((lines (ldict-ref em 'body))) + (when (not (null? lines)) + (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 reminder email body (define (reminder-email-body mr) (let ((C identity) @@ -78,24 +99,6 @@ (subject . "Připomínka členských příspěvků / Membership fees reminder") (body . ,(reminder-email-body mr))))) - ;; Prints email to the console - (define (print-notification-email em) - (print "### From: " (ldict-ref em 'from "-")) - (print "### To: " (ldict-ref em 'to)) - (print "### Subject: " (ldict-ref em 'subject)) - (let loop ((lines (ldict-ref em 'body))) - (when (not (null? lines)) - (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-notification-email @@ -106,4 +109,13 @@ (let ((em (make-reminder-email mr))) (send-notification-email em))) + (define (summary-email-body mb) + '("yyy")) + + (define (make-summary-email mb) + (make-ldict + `((to . ,(*summary-mailto*)) + (subject . "xxx") + (body . ,(summary-email-body mb))))) + )