Create skeleton of summary email infrastructure.

This commit is contained in:
Dominik Pantůček 2023-04-17 20:37:47 +02:00
parent 264925b319
commit 863afdc5b4

View file

@ -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)))))
)