summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-03-31 15:14:48 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-03-31 15:14:48 +0200
commit5cb42e9fce80547c7abb77864626fec6d40ed4dd (patch)
tree1109036136eae616e8c55d4c0d5724b702304352
parent9f66dbc6231e2a884f76fa9913a0461887476116 (diff)
Filter missing messages and return defaults on missing headers.
-rw-r--r--mumi/messages.scm9
-rw-r--r--mumi/web/view/html.scm5
2 files changed, 8 insertions, 6 deletions
diff --git a/mumi/messages.scm b/mumi/messages.scm
index 805a518..ed7e5f3 100644
--- a/mumi/messages.scm
+++ b/mumi/messages.scm
@@ -68,10 +68,11 @@ yet. Return new results alongside cached results."
(assoc-ref address 'address))
(define (header message key)
- (assoc-ref (email-headers message) key))
+ (assoc-ref (or (email-headers message) '()) key))
(define-public (sender message)
- (first (header message 'from)))
+ (or (and=> (header message 'from) first)
+ "unknown sender"))
(define-public sender-email
(compose extract-email sender))
@@ -80,7 +81,7 @@ yet. Return new results alongside cached results."
(extract-name (sender message)))
(define-public (date message)
- (header message 'date))
+ (or (header message 'date) "unknown date"))
(define-public (subject message)
(or (header message 'subject) "(no subject)"))
@@ -97,7 +98,7 @@ yet. Return new results alongside cached results."
(define-public (recipients message)
"Return a list of recipient email addresses for the given MESSAGE."
- (let ((headers (email-headers message)))
+ (let ((headers (or (email-headers message) '())))
(filter-map (match-lambda
(((or 'cc 'bcc 'to) val) val)
(_ #f)) headers)))
diff --git a/mumi/web/view/html.scm b/mumi/web/view/html.scm
index 363b97d..2b8df5b 100644
--- a/mumi/web/view/html.scm
+++ b/mumi/web/view/html.scm
@@ -283,7 +283,7 @@ some examples.")
(define id (bug-num bug))
(define messages (patch-messages id))
(define parties (sort (filter (compose (negate bot?) extract-email)
- (participants messages))
+ (participants (filter identity messages)))
(lambda (a b)
(string< (extract-email a)
(extract-email b)))))
@@ -421,7 +421,8 @@ some examples.")
;; Ignore messages
;; without body, and
;; internal messages.
- (and (email-body msg)
+ (and msg
+ (email-body msg)
(not (internal-message? msg))))
messages)))
(map (lambda (message-number msg previous-subject)