summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2022-06-04 10:32:34 +0200
committerRicardo Wurmus <rekado@elephly.net>2022-06-04 10:32:34 +0200
commite3dfc51d3a5fff5ed05b9859560dc1502b3bcc8b (patch)
tree61841e8c324ef2c932e6e51045f7c96d23f90cb7
parent43839c8085b5b02e6e8829bcfb47a04b29a37a86 (diff)
xapian: Store hash of message id when indexing files.
-rw-r--r--mumi/xapian.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/mumi/xapian.scm b/mumi/xapian.scm
index 925f67b..8024c6d 100644
--- a/mumi/xapian.scm
+++ b/mumi/xapian.scm
@@ -1,5 +1,5 @@
;;; mumi -- Mediocre, uh, mail interface
-;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020, 2022 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020 Arun Isaac <arunisaac@systemreboot.net>
;;;
;;; This program is free software: you can redistribute it and/or
@@ -83,6 +83,14 @@ messages and index their contents in the Xapian database at DBPATH."
(match (assoc-ref (email-headers (last emails)) 'date)
((? string? s) #f)
(date date)))
+ ;; Store the message ids as base64 strings of all
+ ;; messages.
+ (msgids
+ (string-join (map (compose number->string string-hash)
+ (filter-map (lambda (headers)
+ (assoc-ref headers 'message-id))
+ (map email-headers emails)))
+ " "))
(text
(string-join (map (match-lambda
((($ <mime-entity> headers body) ...)
@@ -123,6 +131,7 @@ messages and index their contents in the Xapian database at DBPATH."
((bug-done bug) "done")
(else "open")) #:prefix "XSTATUS")
(index-text! term-generator file #:prefix "F")
+ (index-text! term-generator msgids #:prefix "XU")
;; Index subject and body without prefixes for general
;; search.
@@ -278,7 +287,8 @@ intact."
("owner" . "XO")
("severity" . "XS")
("tag" . "XT")
- ("status" . "XSTATUS"))))
+ ("status" . "XSTATUS")
+ ("msgid" . "XU"))))
(enq (enquire db query)))
;; Collapse on mergedwith value
(Enquire-set-collapse-key enq 2 1)