Switch to processing emails as bytevectors

This is better, as different parts of the email might be encoded differently,
and guile-email will take care of this if handed a bytevector.
This commit is contained in:
Christopher Baines 2019-09-26 18:08:12 +01:00
parent bb94f6dd05
commit 759b75257e

View file

@ -23,6 +23,8 @@
(use-modules (srfi srfi-1) (use-modules (srfi srfi-1)
(srfi srfi-37) (srfi srfi-37)
(ice-9 textual-ports) (ice-9 textual-ports)
(ice-9 binary-ports)
(rnrs bytevectors)
(squee) (squee)
(email email) (email email)
(guix-data-service database) (guix-data-service database)
@ -31,23 +33,22 @@
(with-postgresql-connection (with-postgresql-connection
"process-branch-updated-email" "process-branch-updated-email"
(lambda (conn) (lambda (conn)
(let* ((email-string (let* ((email-bytevector
(get-string-all (current-input-port))) (get-bytevector-all (current-input-port))))
(email (catch
(catch #t
#t (lambda ()
(lambda () (with-throw-handler #t
(parse-email email-string)) (lambda ()
(lambda (key . args) (enqueue-job-for-email
(display "\nerror: while processing email\n" conn
(current-error-port)) (parse-email email-bytevector)))
(simple-format (current-error-port) (lambda (key . args)
"~A: ~A\n\n" (display "\nerror: while parsing email\n"
key (current-error-port))
args) (simple-format (current-error-port)
(display email-string (current-error-port)) "~A: ~A\n\n"
(display "\n\n" (current-error-port)) key
#f)))) args)
(when email (display-backtrace (make-stack #t) (current-error-port)))))
(enqueue-job-for-email conn email))))) (lambda (key . args) #f)))))