email optionally uses criteria from message (#547)

* email optionally uses criteria from message

Allows for generation of detailed queries through flows when triggering an email
fetch in IMAP.

* use the same default as a new email node

When the criteria is set from a message, if there is no criteria use the same default as a new node.
This commit is contained in:
Luis Mario Domenzain
2019-05-29 13:45:54 +02:00
committed by Dave Conway-Jones
parent 877763aae9
commit 16130362fc
5 changed files with 9 additions and 3 deletions

View File

@@ -352,7 +352,10 @@ module.exports = function(RED) {
return;
}
else {
imap.search([ node.criteria ], function(err, results) {
var criteria = ((node.criteria === '_msg_')?
(msg.criteria || ["UNSEEN"]):
([node.criteria]));
imap.search(criteria, function(err, results) {
if (err) {
node.status({fill:"red", shape:"ring", text:"email.status.foldererror"});
node.error(RED._("email.errors.fetchfail", {folder:node.box}),err);