Added node warnings when message properties override set node properties

This commit is contained in:
Anna Thomas
2014-11-03 13:41:45 +00:00
parent 9f925140c9
commit 069a47f35a
6 changed files with 44 additions and 15 deletions

View File

@@ -70,8 +70,8 @@
<script type="text/x-red" data-help-name="e-mail">
<p>Sends the <b>msg.payload</b> as an email, with a subject of <b>msg.topic</b>.</p>
<p>The default message recipient can be configured in the node, if it is left blank it should be set in an incoming message on <b>msg.to</b>.</p>
<!-- <p>It sends the message to the configured recipient <i>only</i>.</p> -->
<p>You may dynamically overide the default recipient by setting a <b>msg.to</b> property.</p>
<!-- <p><b>msg.topic</b> is used to set the subject of the email, and <b>msg.payload</b> is the body text.</p> -->
</script>

View File

@@ -72,6 +72,9 @@ module.exports = function(RED) {
if (smtpTransport) {
node.status({fill:"blue",shape:"dot",text:"sending"});
var payload = RED.util.ensureString(msg.payload);
if (msg.to && node.name) {
node.warn("Deprecated: msg properties should not override set node properties. See bit.ly/nr-override-msg-props");
}
smtpTransport.sendMail({
from: node.userid, // sender address
to: msg.to || node.name, // comma separated list of addressees
@@ -243,4 +246,4 @@ module.exports = function(RED) {
global: { type:"boolean"}
}
});
}
};