From a058999f4cd41423002d3745c017c860791c83d8 Mon Sep 17 00:00:00 2001 From: wooferguy Date: Wed, 12 Jul 2023 07:24:38 +1200 Subject: [PATCH] Pushover ttl Bug Fix (#1017) * 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 * Fix: Warnings with no ttl Check if ttl exists before sanitizing * Add: Allow string ttl If ttl is a string, parse to integer and check validity --------- Co-authored-by: Dave Conway-Jones --- social/pushover/57-pushover.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/social/pushover/57-pushover.js b/social/pushover/57-pushover.js index 3a77bbd7..14ae64f6 100644 --- a/social/pushover/57-pushover.js +++ b/social/pushover/57-pushover.js @@ -63,9 +63,14 @@ 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 (ttl !== null) { + if(typeof ttl === "string") { + ttl = parseInt(ttl); + } + if(isNaN(ttl) || !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') {