summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-11-11 20:43:04 +0100
committerRicardo Wurmus <rekado@elephly.net>2018-11-11 20:43:04 +0100
commit0c224d253cfb4e47a01d6185b0d8986d58b63e28 (patch)
tree7a4a23d61e7fc9c86ab36c48f1c2b37348f49035
parent648311b9b9d9d974fb2d76dacfe956fc7b842401 (diff)
Handle nested mime entries recursively.
* mumi/web/view/utils.scm (display-message-body): Apply display-mime-entity recursively.
-rw-r--r--mumi/web/view/utils.scm26
1 files changed, 13 insertions, 13 deletions
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
+ (($ <mime-entity> headers (? string? body))
+ (apply display-multipart-chunk `(,headers ,body ,path)))
+ ;; Message parts can be nested.
+ (($ <mime-entity> 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
- (($ <mime-entity> headers (? string? body))
- (display-multipart-chunk headers body part-num))
- ;; Message parts can be nested.
- (($ <mime-entity> headers sub-parts)
- (map (lambda (part sub-part-num)
- (match part
- (($ <mime-entity> 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.