diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2020-05-12 23:07:18 +0200 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2020-05-12 23:07:18 +0200 |
commit | 4aa710917d9ac9fe66ba939f73c062a71dffced0 (patch) | |
tree | 6bc3a5f60d162d531ffcca1b834c6e73c2191ad2 | |
parent | 31871a7a1ee2e7ae2cde4fe2847159fafff83380 (diff) |
messages: Do not use define-public.
-rw-r--r-- | mumi/messages.scm | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/mumi/messages.scm b/mumi/messages.scm index de2a30b..cba4896 100644 --- a/mumi/messages.scm +++ b/mumi/messages.scm @@ -42,7 +42,24 @@ bugs-by-severity multipart-message? - extract-attachment)) + extract-attachment + + extract-name + extract-email + sender + sender-email + sender-name + date + subject + message-id + participants + recipients + closing? + bot? + internal-message? + + issue-messages + process-query)) (define (status-with-cache ids) "Invoke GET-STATUS, but only on those IDS that have not been cached @@ -57,64 +74,64 @@ yet. Return new results alongside cached results." ;; Return everything from cache (sort (append cached new) (lambda (a b) (< (bug-num a) (bug-num b)))))) -(define-public (extract-name address) +(define (extract-name address) (or (assoc-ref address 'name) (and=> (assoc-ref address 'address) (lambda (address) (string-take address (string-index address #\@)))) "Somebody")) -(define-public (extract-email address) +(define (extract-email address) (assoc-ref address 'address)) (define (header message key) (assoc-ref (or (email-headers message) '()) key)) -(define-public (sender message) +(define (sender message) (or (and=> (header message 'from) first) '((name . "Unknown sender") (address . "unknown")))) -(define-public sender-email +(define sender-email (compose extract-email sender)) -(define-public (sender-name message) +(define (sender-name message) (extract-name (sender message))) -(define-public (date message) +(define (date message) (or (header message 'date) "unknown date")) -(define-public (subject message) +(define (subject message) (or (header message 'subject) "(no subject)")) -(define-public (message-id message) +(define (message-id message) (header message 'message-id)) -(define-public (participants messages) +(define (participants messages) "Return a list of unique senders in the conversion." (apply lset-adjoin (lambda (a b) (string= (extract-email a) (extract-email b))) '() (map sender messages))) -(define-public (recipients message) +(define (recipients message) "Return a list of recipient email addresses for the given MESSAGE." (let ((headers (or (email-headers message) '()))) (filter-map (match-lambda (((or 'cc 'bcc 'to) val) val) (_ #f)) headers))) -(define-public (closing? message id) +(define (closing? message id) "Is this MESSAGE closing this bug ID?" (let ((done (string-append (number->string id) "-done"))) (and=> (header message 'x-debbugs-envelope-to) (cut string= <> done)))) -(define-public (bot? address) +(define (bot? address) (string= "help-debbugs@gnu.org" address)) -(define-public (internal-message? message) +(define (internal-message? message) (bot? (sender-email message))) @@ -154,7 +171,7 @@ we have to do this in a very convoluted way." ;; We would like to use get-bug-log here, but it often returns ;; truncated messages. This is a known bug upstream. -(define-public (issue-messages bug-id) +(define (issue-messages bug-id) "Return list of messages relating to the issue BUG-ID. Cache the result for a while." (define archived-log @@ -228,7 +245,7 @@ about." (define punctuation? (cut char-set-contains? char-set:punctuation <>)) -(define-public (process-query query) +(define (process-query query) "Process the QUERY string and return a list of query terms and sets that need to overlap the result set." ;; Xapian doesn't like punctuation. Replace with spaces. Leave |