Pushover TTL (#1013)

* TTL Functionality

Pick up msg.ttl and pass it to REST API, checking it is a positive integer first.

* Update help doc

Reference ttl parameter in api docs
This commit is contained in:
wooferguy 2023-06-24 20:54:34 +12:00 committed by GitHub
parent 21b92d4894
commit 51dc002a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -86,6 +86,7 @@
<p><code>msg.sound</code>: set the notification sound, <i><a href="https://pushover.net/api#sounds" target="_new">see the available options</a></i></p>
<p><code>msg.retry</code>: set retry interval for Emergency priority (2) messages, <i><a href="https://pushover.net/api#priority" target="_new">see details</a></i></p>
<p><code>msg.expire</code>: set retry duration for Emergency priority (2) messages, <i><a href="https://pushover.net/api#priority" target="_new">see details</a></i></p>
<p><code>msg.ttl</code>: set time to live duration on anything except Emergency priority (2) messages, <i><a href="https://pushover.net/api#ttl" target="_new">see details</a></i></p>
<p><code>msg.callback</code>: set the callback url for Emergency priority (2) messages, <i><a href="https://pushover.net/api/receipts#callback" target="_new">see details</a></i></p>
<p><code>msg.tags</code>: set tags for Emergency priority (2) messages, <i><a href="https://pushover.net/api/receipts#cancel_by_tag" target="_new">see details</a></i></p>
<p>Uses Pushover. See <i><a href="https://pushover.net" target="_new">this link</a></i> for more details.</p>

View File

@ -41,6 +41,7 @@ module.exports = function(RED) {
var attachment = msg.attachment || null;
var retry = msg.retry || 30;
var expire = msg.expire || 600;
var ttl = msg.ttl || null;
var callback = msg.callback || null;
var tags = msg.tags || null;
if (isNaN(pri)) {pri=0;}
@ -62,6 +63,10 @@ module.exports = function(RED) {
expire = 10800;
node.warn("Expire time too high, using maximum setting of 10800s (3 hours) retry duration");
}
if (!Number.isInteger(ttl) || ttl<=0) {
ttl = null;
node.warn("No valid number for TTL found, not set");
}
if (typeof msg.payload === 'undefined') { msg.payload = "(undefined msg.payload)"; }
if (typeof(msg.payload) === 'object') {
msg.payload = JSON.stringify(msg.payload);
@ -74,6 +79,7 @@ module.exports = function(RED) {
priority: pri,
retry: retry,
expire: expire,
ttl: ttl,
html: html
};
if (dev) { pushmsg.device = dev; }