mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-08 22:24:29 +08:00
do not include attachments in SEARCHable message content
This commit is contained in:
parent
157ef263d7
commit
44012e79a8
2 changed files with 13 additions and 9 deletions
|
@ -111,9 +111,10 @@ class Indexer {
|
||||||
*
|
*
|
||||||
* @param {Object} mimeTree Parsed mimeTree object
|
* @param {Object} mimeTree Parsed mimeTree object
|
||||||
* @param {Boolean} textOnly If true, do not include the message header in the response
|
* @param {Boolean} textOnly If true, do not include the message header in the response
|
||||||
|
* @param {Boolean} skipExternal If true, do not include the external nodes
|
||||||
* @return {Stream} Message stream
|
* @return {Stream} Message stream
|
||||||
*/
|
*/
|
||||||
rebuild(mimeTree, textOnly) {
|
rebuild(mimeTree, textOnly, skipExternal) {
|
||||||
let res = new PassThrough();
|
let res = new PassThrough();
|
||||||
let first = true;
|
let first = true;
|
||||||
let root = true;
|
let root = true;
|
||||||
|
@ -152,7 +153,7 @@ class Indexer {
|
||||||
|
|
||||||
if (node.boundary) {
|
if (node.boundary) {
|
||||||
append('--' + node.boundary);
|
append('--' + node.boundary);
|
||||||
} else if (node.attachmentId) {
|
} else if (node.attachmentId && !skipExternal) {
|
||||||
append(false, true); // force newline between header and contents
|
append(false, true); // force newline between header and contents
|
||||||
|
|
||||||
let limiter = new LengthLimiter(node.size);
|
let limiter = new LengthLimiter(node.size);
|
||||||
|
@ -245,6 +246,7 @@ class Indexer {
|
||||||
let attachmentId = new ObjectID();
|
let attachmentId = new ObjectID();
|
||||||
let contentType = node.parsedHeader['content-type'] && node.parsedHeader['content-type'].value || 'application/octet-stream';
|
let contentType = node.parsedHeader['content-type'] && node.parsedHeader['content-type'].value || 'application/octet-stream';
|
||||||
let fileName = (node.parsedHeader['content-disposition'] && node.parsedHeader['content-disposition'].params && node.parsedHeader['content-disposition'].params.filename) || (node.parsedHeader['content-type'] && node.parsedHeader['content-type'].params && node.parsedHeader['content-type'].params.name) || false;
|
let fileName = (node.parsedHeader['content-disposition'] && node.parsedHeader['content-disposition'].params && node.parsedHeader['content-disposition'].params.filename) || (node.parsedHeader['content-type'] && node.parsedHeader['content-type'].params && node.parsedHeader['content-type'].params.name) || false;
|
||||||
|
let transferEncoding = node.parsedHeader['content-transfer-encoding'] || '7bit';
|
||||||
|
|
||||||
if (fileName) {
|
if (fileName) {
|
||||||
try {
|
try {
|
||||||
|
@ -262,6 +264,7 @@ class Indexer {
|
||||||
messages: [messageId],
|
messages: [messageId],
|
||||||
fileName,
|
fileName,
|
||||||
contentType,
|
contentType,
|
||||||
|
transferEncoding,
|
||||||
created: new Date()
|
created: new Date()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -418,9 +421,10 @@ class Indexer {
|
||||||
*
|
*
|
||||||
* @param {Object} mimeTree Parsed mimeTree object
|
* @param {Object} mimeTree Parsed mimeTree object
|
||||||
* @param {Object} selector What data to return
|
* @param {Object} selector What data to return
|
||||||
|
* @param {Boolean} skipExternal If true, do not include the external nodes
|
||||||
* @return {String} node contents
|
* @return {String} node contents
|
||||||
*/
|
*/
|
||||||
getContents(mimeTree, selector) {
|
getContents(mimeTree, selector, skipExternal) {
|
||||||
let node = mimeTree;
|
let node = mimeTree;
|
||||||
|
|
||||||
if (typeof selector === 'string') {
|
if (typeof selector === 'string') {
|
||||||
|
@ -445,10 +449,10 @@ class Indexer {
|
||||||
case 'content':
|
case 'content':
|
||||||
if (!selector.path) {
|
if (!selector.path) {
|
||||||
// BODY[]
|
// BODY[]
|
||||||
return this.rebuild(node);
|
return this.rebuild(node, false, skipExternal);
|
||||||
}
|
}
|
||||||
// BODY[1.2.3]
|
// BODY[1.2.3]
|
||||||
return this.rebuild(node, true);
|
return this.rebuild(node, true, skipExternal);
|
||||||
|
|
||||||
case 'header':
|
case 'header':
|
||||||
if (!selector.path) {
|
if (!selector.path) {
|
||||||
|
@ -487,10 +491,10 @@ class Indexer {
|
||||||
case 'text':
|
case 'text':
|
||||||
if (!selector.path) {
|
if (!selector.path) {
|
||||||
// BODY[TEXT] mail body without headers
|
// BODY[TEXT] mail body without headers
|
||||||
return this.rebuild(node, true);
|
return this.rebuild(node, true, skipExternal);
|
||||||
} else if (node.message) {
|
} else if (node.message) {
|
||||||
// BODY[1.2.3.TEXT] embedded message/rfc822 body without headers
|
// BODY[1.2.3.TEXT] embedded message/rfc822 body without headers
|
||||||
return this.rebuild(node.message, true);
|
return this.rebuild(node.message, true, skipExternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|
|
@ -59,7 +59,7 @@ let queryHandlers = {
|
||||||
body(message, query, callback) {
|
body(message, query, callback) {
|
||||||
let data = indexer.getContents(message.mimeTree, {
|
let data = indexer.getContents(message.mimeTree, {
|
||||||
type: 'text'
|
type: 'text'
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
let resolveData = next => {
|
let resolveData = next => {
|
||||||
if (data.type !== 'stream') {
|
if (data.type !== 'stream') {
|
||||||
|
@ -96,7 +96,7 @@ let queryHandlers = {
|
||||||
text(message, query, callback) {
|
text(message, query, callback) {
|
||||||
let data = indexer.getContents(message.mimeTree, {
|
let data = indexer.getContents(message.mimeTree, {
|
||||||
type: 'content'
|
type: 'content'
|
||||||
});
|
}, true);
|
||||||
|
|
||||||
let resolveData = next => {
|
let resolveData = next => {
|
||||||
if (data.type !== 'stream') {
|
if (data.type !== 'stream') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue