index List-ID headers

This commit is contained in:
Andris Reinman 2018-09-25 11:01:56 +03:00
parent 59de74a312
commit 3fb0b13a79

View file

@ -14,7 +14,7 @@ const openpgp = require('openpgp');
const parseDate = require('../imap-core/lib/parse-date');
// index only the following headers for SEARCH
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index'];
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index', 'list-id'];
openpgp.config.commentstring = 'Plaintext message encrypted by WildDuck Mail Server';
@ -1218,6 +1218,18 @@ class MessageHandler {
// store indexed value as lowercase for easier SEARCHing
value = value.toLowerCase();
switch (key) {
case 'list-id':
// only index the actual ID of the list
if (value.indexOf('<') >= 0) {
let m = value.match(/<([^>]+)/);
if (m && m[1] && m[1].trim()) {
value = m[1].trim();
}
}
break;
}
// trim long values as mongodb indexed fields can not be too long
if (Buffer.byteLength(key, 'utf-8') >= 255) {
key = Buffer.from(key)