Skip to content

Commit

Permalink
allow strings as notification actions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-tatar committed Jun 23, 2023
1 parent ee0be0b commit c1248a6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/nodes/nora-notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { RateLimitingError } from '../nora/sync';
import { getClose, getId, getValue, handleNodeInput } from './util';

const JSON_ACTION_PREFIX = 'json:';
const LINK_ACTION_PREFIX = 'https://';

module.exports = function (RED: any) {
RED.nodes.registerType('noraf-notify', function (this: NodeInterface, config: any) {
Expand Down Expand Up @@ -98,7 +99,7 @@ module.exports = function (RED: any) {
if (typeof msg.payload === 'object' && Array.isArray(msg.payload.actions) && msg.payload.actions.length) {
msg.payload.actions = msg.payload.actions.map((v: any) => ({
...v,
action: typeof v.action === 'string'
action: typeof v.action === 'string' && v.action.startsWith(LINK_ACTION_PREFIX)
? v.action
: JSON_ACTION_PREFIX + JSON.stringify(v.action)
}));
Expand Down

0 comments on commit c1248a6

Please sign in to comment.