let pushover take an attachment object

This commit is contained in:
Dave Conway-Jones
2025-07-04 11:40:34 +01:00
parent 9a67173ec2
commit 06a9c48395
3 changed files with 7 additions and 4 deletions

View File

@@ -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);

View File

@@ -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)

View File

@@ -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"