From: Ricardo Wurmus Date: Sun, 11 Nov 2018 19:43:04 +0000 (+0100) Subject: Handle nested mime entries recursively. X-Git-Tag: 0.0.1~246 X-Git-Url: https://git.elephly.net/?p=software%2Fmumi.git;a=commitdiff_plain;h=0c224d253cfb4e47a01d6185b0d8986d58b63e28 Handle nested mime entries recursively. * mumi/web/view/utils.scm (display-message-body): Apply display-mime-entity recursively. --- diff --git a/mumi/web/view/utils.scm b/mumi/web/view/utils.scm index 69df0c0..2c58467 100644 --- a/mumi/web/view/utils.scm +++ b/mumi/web/view/utils.scm @@ -108,7 +108,7 @@ (define (display-message-body bug-num message-number message) "Convenience procedure to render MESSAGE (part of bug with number BUG-NUM), even when it is a multipart message." - (define (display-multipart-chunk headers body . path) + (define (display-multipart-chunk headers body path) (define (attachment-url) (string-append "/issue/" (number->string bug-num) @@ -147,22 +147,22 @@ BUG-NUM), even when it is a multipart message." (a (@ (href ,(attachment-url))) "Download")) ,(prettify body)))))) + (define (display-mime-entity entity . path) + (match entity + (($ headers (? string? body)) + (apply display-multipart-chunk `(,headers ,body ,path))) + ;; Message parts can be nested. + (($ headers sub-parts) + (map (lambda (part sub-part-num) + (apply display-mime-entity part + (append path (list sub-part-num)))) + sub-parts + (iota (length sub-parts)))))) (cond ((multipart-message? message) (let ((parts (email-body message))) (map (lambda (part part-num) - (match part - (($ headers (? string? body)) - (display-multipart-chunk headers body part-num)) - ;; Message parts can be nested. - (($ headers sub-parts) - (map (lambda (part sub-part-num) - (match part - (($ headers body) - (display-multipart-chunk - headers body part-num sub-part-num)))) - sub-parts - (iota (length sub-parts)))))) + (display-mime-entity part part-num)) parts (iota (length parts))))) ;; Regular message with a simple body.