summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mumi/messages.scm11
-rw-r--r--mumi/web/download.scm31
2 files changed, 25 insertions, 17 deletions
diff --git a/mumi/messages.scm b/mumi/messages.scm
index e4222e9..5cf3390 100644
--- a/mumi/messages.scm
+++ b/mumi/messages.scm
@@ -1,6 +1,6 @@
;;; mumi -- Mediocre, uh, mail interface
;;; Copyright © 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
-;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2018, 2019 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This program is free software: you can redistribute it and/or
;;; modify it under the terms of the GNU Affero General Public License
@@ -122,8 +122,13 @@ we have to do this in a very convoluted way."
(lambda (bug)
(and=> (nth msg-num (patch-messages id))
(lambda (msg)
- (and (multipart-message? msg)
- (traverse path (email-body msg))))))))
+ (cond
+ ((multipart-message? msg)
+ (traverse path (email-body msg)))
+ (else
+ (match path
+ (() msg)
+ (_ #f)))))))))
(define-public (patch-messages id)
diff --git a/mumi/web/download.scm b/mumi/web/download.scm
index 9037b64..91a8bc3 100644
--- a/mumi/web/download.scm
+++ b/mumi/web/download.scm
@@ -32,22 +32,25 @@
"Handle download of an attachment for bug ID, message number
MSG-NUM, in the possibly nested message part identified by the list
PATH."
+ (define (html-response headers body)
+ (list (filter-map (match-lambda
+ (('content-type . vals)
+ (list 'content-type
+ (or (assoc-ref vals 'type) 'text)))
+ (('content-disposition . vals)
+ (list 'content-disposition
+ (assoc-ref vals 'type)
+ `(filename . ,(or (assoc-ref vals 'filename)
+ "attachment"))))
+ (_ #f))
+ headers)
+ body))
+
(or (and=> (extract-attachment id msg-num path)
(match-lambda
((? mime-entity? entry)
- (let ((headers (mime-entity-headers entry))
- (body (mime-entity-body entry)))
- (list (filter-map (match-lambda
- (('content-type . vals)
- (list 'content-type
- (or (assoc-ref vals 'type) 'text)))
- (('content-disposition . vals)
- (list 'content-disposition
- (assoc-ref vals 'type)
- `(filename . ,(or (assoc-ref vals 'filename)
- "attachment"))))
- (_ #f))
- headers)
- body)))
+ (html-response (mime-entity-headers entry) (mime-entity-body entry)))
+ ((? email? entry)
+ (html-response (email-headers entry) (email-body entry)))
(_ #f)))
(apply render-html (unknown id))))