email node - remove promises for node8

and fixup tests
This commit is contained in:
Dave Conway-Jones 2020-10-19 21:33:32 +01:00
parent ffa5761756
commit 6f351943cb
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
3 changed files with 41 additions and 38 deletions

View File

@ -529,11 +529,9 @@ module.exports = function(RED) {
disabledCommands: ['AUTH', 'STARTTLS'],
onData: function (stream, session, callback) {
simpleParser(stream, {
skipTextToHtml: true,
skipTextLinks: true
})
.then(parsed => {
simpleParser(stream, { skipTextToHtml:true, skipTextLinks:true }, (err, parsed) => {
if (err) { node.error(RED._("email.errors.parsefail"),err); }
else {
node.status({fill:"green", shape:"dot", text:""});
var msg = {}
msg.payload = parsed.text;
@ -557,9 +555,9 @@ module.exports = function(RED) {
else { msg.attachments = []; }
node.send(msg); // Propagate the message down the flow
setTimeout(function() { node.status({})}, 500);
})
.catch(err => { node.error(RED._("email.errors.parsefail"),err); })
.finally(callback);
}
callback();
});
}
});

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-email",
"version": "1.8.0",
"version": "1.8.1",
"description": "Node-RED nodes to send and receive simple emails.",
"dependencies": {
"imap": "^0.8.19",

View File

@ -225,6 +225,7 @@ describe('email Node', function () {
n2.on("input", function(msg) {
//console.log("GOT",msg);
try {
msg.should.have.a.property("payload",'Hello World\n');
msg.should.have.a.property("topic","Test");
msg.should.have.a.property("from",'foo@example.com');
@ -232,6 +233,10 @@ describe('email Node', function () {
msg.should.have.a.property("attachments");
msg.should.have.a.property("header");
done();
}
catch(e) {
done(e)
}
});
n3.emit("input", {