mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-10-15 00:06:14 +08:00
v1.0.44
This commit is contained in:
parent
fbdbc404c5
commit
9ca6ac4cdb
2 changed files with 10 additions and 7 deletions
|
@ -13,6 +13,10 @@ const counters = require('./counters');
|
|||
// how many modifications to cache before writing
|
||||
const BULK_BATCH_SIZE = 150;
|
||||
const SCHEMA_VERSION = '1.0';
|
||||
// how much plaintext to store. this is indexed with a fulltext index
|
||||
const MAX_PLAINTEXT_CONTENT = 2 * 1024;
|
||||
// how much HTML content to store. not indexed
|
||||
const MAX_HTML_CONTENT = 300 * 1024;
|
||||
|
||||
// index only the following headers for SEARCH
|
||||
const INDEXED_HEADERS = ['to', 'cc', 'subject', 'from', 'sender', 'reply-to', 'message-id', 'thread-index'];
|
||||
|
@ -165,11 +169,10 @@ class MessageHandler {
|
|||
message.ha = false;
|
||||
}
|
||||
|
||||
let maxTextLength = 300 * 1024;
|
||||
|
||||
if (maildata.text) {
|
||||
message.text = maildata.text.replace(/\r\n/g, '\n').trim();
|
||||
message.text = message.text.length <= maxTextLength ? message.text : message.text.substr(0, maxTextLength);
|
||||
// text is indexed with a fulltext index, so only store the beginning of it
|
||||
message.text = message.text.length <= MAX_PLAINTEXT_CONTENT ? message.text : message.text.substr(0, MAX_PLAINTEXT_CONTENT);
|
||||
message.intro = message.text.replace(/\s+/g, ' ').trim();
|
||||
if (message.intro.length > 128) {
|
||||
let intro = message.intro.substr(0, 128);
|
||||
|
@ -185,16 +188,16 @@ class MessageHandler {
|
|||
let htmlSize = 0;
|
||||
message.html = maildata.html
|
||||
.map(html => {
|
||||
if (htmlSize >= maxTextLength || !html) {
|
||||
if (htmlSize >= MAX_HTML_CONTENT || !html) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (htmlSize + Buffer.byteLength(html) <= maxTextLength) {
|
||||
if (htmlSize + Buffer.byteLength(html) <= MAX_HTML_CONTENT) {
|
||||
htmlSize += Buffer.byteLength(html);
|
||||
return html;
|
||||
}
|
||||
|
||||
html = html.substr(0, htmlSize + Buffer.byteLength(html) - maxTextLength);
|
||||
html = html.substr(0, htmlSize + Buffer.byteLength(html) - MAX_HTML_CONTENT);
|
||||
htmlSize += Buffer.byteLength(html);
|
||||
return html;
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wildduck",
|
||||
"version": "1.0.43",
|
||||
"version": "1.0.44",
|
||||
"description": "IMAP server built with Node.js and MongoDB",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
|
|
Loading…
Add table
Reference in a new issue