feat(ntfy): add send message action
This commit is contained in:
3
packages/backend/src/apps/ntfy/actions/index.ts
Normal file
3
packages/backend/src/apps/ntfy/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import sendMessage from './send-message';
|
||||
|
||||
export default [sendMessage];
|
103
packages/backend/src/apps/ntfy/actions/send-message/index.ts
Normal file
103
packages/backend/src/apps/ntfy/actions/send-message/index.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import qs from 'qs';
|
||||
import defineAction from '../../../../helpers/define-action';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Send message',
|
||||
key: 'sendMessage',
|
||||
description: 'Sends a message to a topic you specify.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Topic',
|
||||
key: 'topic',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Target topic name.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Message body',
|
||||
key: 'message',
|
||||
type: 'string' as const,
|
||||
required: true,
|
||||
description: 'Message body to be sent, set to triggered if empty or not passed.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Title',
|
||||
key: 'title',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Message title.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Email',
|
||||
key: 'email',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'E-mail address for e-mail notifications.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Click URL',
|
||||
key: 'click',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Website opened when notification is clicked.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Attach file by URL',
|
||||
key: 'attach',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'URL of an attachment.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Filename',
|
||||
key: 'filename',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'File name of the attachment.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Delay',
|
||||
key: 'delay',
|
||||
type: 'string' as const,
|
||||
required: false,
|
||||
description: 'Timestamp or duration for delayed delivery. For example, 30min or 9am.',
|
||||
variables: true,
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
topic,
|
||||
message,
|
||||
title,
|
||||
email,
|
||||
click,
|
||||
attach,
|
||||
filename,
|
||||
delay
|
||||
} = $.step.parameters;
|
||||
const payload = {
|
||||
topic,
|
||||
message,
|
||||
title,
|
||||
email,
|
||||
click,
|
||||
attach,
|
||||
filename,
|
||||
delay
|
||||
};
|
||||
|
||||
const response = await $.http.post('/', payload);
|
||||
|
||||
$.setActionItem({
|
||||
raw: response.data,
|
||||
});
|
||||
},
|
||||
});
|
@@ -1,6 +1,7 @@
|
||||
import defineApp from '../../helpers/define-app';
|
||||
import addAuthHeader from './common/add-auth-header';
|
||||
import auth from './auth';
|
||||
import actions from './actions';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Ntfy',
|
||||
@@ -13,4 +14,5 @@ export default defineApp({
|
||||
primaryColor: '56bda8',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
actions,
|
||||
});
|
||||
|
Reference in New Issue
Block a user