From 06a9c48395ab8ba707a0f265162df5c0c81dd74b Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Fri, 4 Jul 2025 11:40:34 +0100 Subject: [PATCH] let pushover take an attachment object --- social/pushover/57-pushover.js | 7 +++++-- social/pushover/README.md | 2 +- social/pushover/package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/social/pushover/57-pushover.js b/social/pushover/57-pushover.js index 14ae64f6..5520dc07 100644 --- a/social/pushover/57-pushover.js +++ b/social/pushover/57-pushover.js @@ -118,10 +118,13 @@ module.exports = function(RED) { // Unset these temporary values attachmentBuffer = attachmentString = undefined; // attach the buffer - pushmsg.file = { data: attachment }; + pushmsg.file = { data:attachment }; + } + else if (typeof(msg.attachment) === 'object' && msg.attachment.hasOwnProperty('name') && msg.attachment.hasOwnProperty('data')) { + pushmsg.file = msg.attachment; } else if (attachment) { - node.error("[57-pushover.js] Error: attachment property must be a path to a local file or a Buffer containing an image"); + node.error("[57-pushover.js] Error: attachment property must be a path to a local file or a Buffer containing an image, or an object containing both name and data properties"); return; } pushMessage(pushmsg,msg); diff --git a/social/pushover/README.md b/social/pushover/README.md index 1e664694..152ac5e6 100644 --- a/social/pushover/README.md +++ b/social/pushover/README.md @@ -21,7 +21,7 @@ Optionally uses `msg.topic` to set the configuration, if not already set in the - `msg.device`: to set the device - `msg.priority`: to set the priority - `msg.topic`: to set the title - - `msg.attachment`: to specify an image to attach to message (path as a string or Buffer containing image) + - `msg.attachment`: to specify an image to attach to message. Either as a path as a string, or Buffer containing image as either binary or base64 encoded, or an object containing "name" and "data" properties. - `msg.url`: to add a web address - `msg.url_title`: to add a url title - `msg.html`: set to true or 1 if message is HTML formatted, see the [supported tags](https://pushover.net/api#html) diff --git a/social/pushover/package.json b/social/pushover/package.json index 3492185c..39f97b04 100644 --- a/social/pushover/package.json +++ b/social/pushover/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-pushover", - "version": "0.2.2", + "version": "0.3.0", "description": "A Node-RED node to send alerts via Pushover", "dependencies": { "pushover-notifications": "^1.2.3"