1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

add option to set criteria witch type of emails should be requested (#519)

This commit is contained in:
Wolfgang Rathgeb 2019-02-11 20:26:45 +01:00 committed by Dave Conway-Jones
parent 31b9cc1f61
commit aa684240d8
3 changed files with 36 additions and 2 deletions

View File

@ -57,6 +57,7 @@
<label for="node-input-dname"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-dname" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-tips" id="node-tip"><span data-i18n="[html]email.tip.cred"></span></div>
</script>
@ -171,6 +172,27 @@
<option value="Delete" data-i18n="email.label.delete"></option>
</select>
</div>
<div class="form-row">
<label for="node-input-criteria"><i class="fa fa-criteria"></i> <span data-i18n="node-red:common.label.criteria"></span></label>
<select type="text" id="node-input-criteria">
<option value="ALL" selected="selected" data-i18n="email.label.all"></option>
<option value="ANSWERED" data-i18n="email.label.answered"></option>
<option value="FLAGGED" data-i18n="email.label.flagged"></option>
<option value="SEEN" selected="selected" data-i18n="email.label.seen"></option>
<option value="UNANSWERED" selected="selected" data-i18n="email.label.unanswered"></option>
<option value="UNFLAGGED" selected="selected" data-i18n="email.label.unflagged"></option>
<option value="UNSEEN" data-i18n="email.label.unseen"></option>
<!--
<option value="DELETED" data-i18n="email.label.delete"></option>
<option value="DRAFT" selected="selected" data-i18n="email.label.none"></option>
<option value="NEW" data-i18n="email.label.delete"></option>
<option value="UNDELETED" data-i18n="email.label.read"></option>
<option value="UNDRAFT" data-i18n="email.label.delete"></option>
<option value="RECENT" data-i18n="email.label.read"></option>
<option value="OLD" data-i18n="email.label.delete"></option>
-->
</select>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
@ -199,9 +221,11 @@
if (protocol === "IMAP") {
$(".node-input-box").show();
$(".node-input-disposition").show();
$(".node-input-criteria").show();
} else {
$(".node-input-box").hide();
$(".node-input-disposition").hide();
$(".node-input-criteria").hide();
}
checkPorts();
});
@ -252,6 +276,7 @@
port: {value:"993",required:true},
box: {value:"INBOX"}, // For IMAP, The mailbox to process
disposition: { value: "Read" }, // For IMAP, the disposition of the read email
criteria: {value: "UNSEEN"},
repeat: {value:"300",required:true},
fetch: {value:"auto"},
inputs: {value:0}

View File

@ -160,6 +160,7 @@ module.exports = function(RED) {
this.useSSL= n.useSSL;
this.protocol = n.protocol || "IMAP";
this.disposition = n.disposition || "None"; // "None", "Delete", "Read"
this.criteria = n.criteria || "UNSEEN"; // "ALL", "ANSWERED", "FLAGGED", "SEEN", "UNANSWERED", "UNFLAGGED", "UNSEEN"
var flag = false;
@ -343,7 +344,7 @@ module.exports = function(RED) {
return;
}
else {
imap.search([ 'UNSEEN' ], function(err, results) {
imap.search([ this.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);

View File

@ -20,7 +20,15 @@
"disposition": "Disposition",
"none": "None",
"read": "Mark Read",
"delete": "Delete"
"delete": "Delete",
"criteria": "Criteria",
"all": "All",
"answered": "Answered",
"flagged": "Flagged",
"seen": "Seen",
"unanswered": "Unanswered",
"unflagged": "Unflagged",
"unseen": "Unseen"
},
"default-message": "__description__\n\nFile from Node-RED is attached: __filename__",
"tip": {