(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)
(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.