This commit is contained in:
Andris Reinman 2018-01-04 12:15:08 +02:00
parent ba35a2f25e
commit 06ad073769
3 changed files with 44 additions and 28 deletions

View file

@ -111,15 +111,15 @@ module.exports = (db, server) => {
let pageNext = result.value.next; let pageNext = result.value.next;
let pagePrevious = result.value.previous; let pagePrevious = result.value.previous;
let filter = query let filter =
? { (query && {
address: { address: {
// cannot use dotless version as this would break domain search // cannot use dotless version as this would break domain search
$regex: query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), $regex: query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'),
$options: '' $options: ''
} }
} }) ||
: {}; {};
db.users.collection('addresses').count(filter, (err, total) => { db.users.collection('addresses').count(filter, (err, total) => {
if (err) { if (err) {

View file

@ -378,12 +378,13 @@ class FilterHandler {
sender, sender,
recipient, recipient,
targets: forwardTargets.size targets:
? Array.from(forwardTargets).map(row => ({ (forwardTargets.size &&
type: row[1].type, Array.from(forwardTargets).map(row => ({
value: row[1].value type: row[1].type,
})) value: row[1].value
: false, }))) ||
false,
chunks, chunks,
chunklen chunklen
@ -570,13 +571,12 @@ class FilterHandler {
response: err ? err : 'Message stored as ' + info.id.toString(), response: err ? err : 'Message stored as ' + info.id.toString(),
error: err error: err
}, },
!isEncrypted (!isEncrypted && {
? { // reuse parsed values
// reuse parsed values mimeTree: messageOpts.prepared.mimeTree,
mimeTree: messageOpts.prepared.mimeTree, maildata: messageOpts.maildata
maildata: messageOpts.maildata }) ||
} false
: false
); );
}); });
}); });

View file

@ -424,7 +424,9 @@ class MessageHandler {
// no need to load extra data when we only need to know the basics // no need to load extra data when we only need to know the basics
queryOpts.fields = { queryOpts.fields = {
_id: true, _id: true,
uid: true uid: true,
outbound: true,
mailbox: true
}; };
} }
@ -535,7 +537,7 @@ class MessageHandler {
messageData._id = messageOpts.id; messageData._id = messageOpts.id;
messageData.uid = newUid; messageData.uid = newUid;
messageOpts.modseq = newModseq; messageData.modseq = newModseq;
messageData.flags = messageOpts.flags; messageData.flags = messageOpts.flags;
this.database.collection('messages').insertOne(messageData, err => { this.database.collection('messages').insertOne(messageData, err => {
@ -570,7 +572,9 @@ class MessageHandler {
ignore: options.session && options.session.id, ignore: options.session && options.session.id,
uid: existingUid, uid: existingUid,
message: existingId, message: existingId,
unseen: messageData.unseen unseen: messageData.unseen,
// modseq is needed to avoid updating mailbox entry
modseq: newModseq
}, },
() => { () => {
this.notifier.addEntries( this.notifier.addEntries(
@ -775,9 +779,19 @@ class MessageHandler {
} }
}, },
{ {
uidNext: true returnOriginal: false,
projection: {
_id: true,
uidNext: true
}
}, },
() => { (err, item) => {
if (err) {
return callback(err);
}
let newModseq = (item && item.value && item.value.modifyIndex) || 1;
let cursor = this.database let cursor = this.database
.collection('messages') .collection('messages')
.find({ .find({
@ -995,7 +1009,9 @@ class MessageHandler {
ignore: options.session && options.session.id, ignore: options.session && options.session.id,
uid: messageUid, uid: messageUid,
message: messageId, message: messageId,
unseen unseen,
// modseq is needed to avoid updating mailbox entry
modseq: newModseq
}); });
if (options.showExpunged) { if (options.showExpunged) {