mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-27 10:21:11 +08:00
Added missing index and address handler
This commit is contained in:
parent
408aadc07f
commit
0587c2934f
2 changed files with 47 additions and 0 deletions
17
indexes.yaml
17
indexes.yaml
|
@ -611,3 +611,20 @@ indexes:
|
|||
name: audit_files_expire
|
||||
key:
|
||||
metadata.info.expires: 1
|
||||
|
||||
- collection: audit.files
|
||||
type: gridfs # index applies to gridfs database
|
||||
index:
|
||||
name: audit_files_addresses
|
||||
key:
|
||||
metadata.audit: 1
|
||||
metadata.addresses.type: 1
|
||||
metadata.addresses.name: 1
|
||||
metadata.addresses.address: 1
|
||||
|
||||
- collection: audit.files
|
||||
type: gridfs # index applies to gridfs database
|
||||
index:
|
||||
name: audit_files_subject
|
||||
key:
|
||||
metadata.subject: 1
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
const ObjectID = require('mongodb').ObjectID;
|
||||
const GridFSBucket = require('mongodb').GridFSBucket;
|
||||
const log = require('npmlog');
|
||||
const libmime = require('libmime');
|
||||
const { normalizeAddress } = require('./tools');
|
||||
|
||||
class AuditHandler {
|
||||
constructor(options) {
|
||||
|
@ -117,6 +119,34 @@ class AuditHandler {
|
|||
metadata.audit = metadata.audit || audit;
|
||||
metadata.date = metadata.date || new Date();
|
||||
|
||||
const headers = metadata.header || {};
|
||||
|
||||
metadata.subject = ([].concat(headers.subject || []).pop() || '').trim();
|
||||
try {
|
||||
metadata.subject = libmime.decodeWords(metadata.subject);
|
||||
} catch (E) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
metadata.addresses = [];
|
||||
[('from', 'to', 'cc', 'bcc')].forEach(type => {
|
||||
if (headers[type] && headers[type].length) {
|
||||
headers[type].forEach(addr => {
|
||||
let entry = {
|
||||
name: addr.name,
|
||||
address: normalizeAddress(addr.address),
|
||||
type
|
||||
};
|
||||
try {
|
||||
entry.name = libmime.decodeWords(entry.name);
|
||||
} catch (E) {
|
||||
// ignore
|
||||
}
|
||||
metadata.addresses.push(entry);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
let result = await new Promise((resolve, reject) => {
|
||||
let stream = this.gridstore.openUploadStreamWithId(id, null, {
|
||||
contentType: 'message/rfc822',
|
||||
|
|
Loading…
Reference in a new issue