feat(pushover): add send a pushover notification action (#1373)
This commit is contained in:
3
packages/backend/src/apps/pushover/actions/index.ts
Normal file
3
packages/backend/src/apps/pushover/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import sendAPushoverNotification from './send-a-pushover-notification';
|
||||||
|
|
||||||
|
export default [sendAPushoverNotification];
|
@@ -0,0 +1,136 @@
|
|||||||
|
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Send a Pushover Notification',
|
||||||
|
key: 'sendPushoverNotification',
|
||||||
|
description:
|
||||||
|
'Generates a Pushover notification on the devices you have subscribed to.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Title',
|
||||||
|
key: 'title',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
description: 'An optional title displayed with the message.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Message',
|
||||||
|
key: 'message',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
description: 'The main message text of your notification.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Priority',
|
||||||
|
key: 'priority',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'Lowest (no notification, just in-app message)', value: -2 },
|
||||||
|
{ label: 'Low (no sound or vibration)', value: -1 },
|
||||||
|
{ label: 'Normal', value: 0 },
|
||||||
|
{ label: 'High (bypass quiet hours, highlight)', value: 1 },
|
||||||
|
{
|
||||||
|
label: 'Emergency (repeat every 30 seconds until acknowledged)',
|
||||||
|
value: 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Sound',
|
||||||
|
key: 'sound',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description: 'Optional sound to override your default.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listSounds',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'URL',
|
||||||
|
key: 'url',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
description: 'URL to display with message.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'URL Title',
|
||||||
|
key: 'urlTitle',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
description:
|
||||||
|
'Title of URL to display, otherwise URL itself will be displayed.',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Devices',
|
||||||
|
key: 'devices',
|
||||||
|
type: 'dynamic' as const,
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'Device',
|
||||||
|
key: 'device',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description:
|
||||||
|
'Restrict sending to just these devices on your account.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listDevices',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const { title, message, priority, sound, url, urlTitle } =
|
||||||
|
$.step.parameters;
|
||||||
|
|
||||||
|
const devices = $.step.parameters.devices as IJSONArray;
|
||||||
|
const allDevices = devices
|
||||||
|
.map((device: IJSONObject) => device.device)
|
||||||
|
.join(',');
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
token: $.auth.data.apiToken,
|
||||||
|
user: $.auth.data.userKey,
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
priority,
|
||||||
|
sound,
|
||||||
|
url,
|
||||||
|
url_title: urlTitle,
|
||||||
|
device: allDevices,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.post('/1/messages.json', payload);
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
4
packages/backend/src/apps/pushover/dynamic-data/index.ts
Normal file
4
packages/backend/src/apps/pushover/dynamic-data/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import listDevices from './list-devices';
|
||||||
|
import listSounds from './list-sounds';
|
||||||
|
|
||||||
|
export default [listDevices, listSounds];
|
@@ -0,0 +1,32 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List devices',
|
||||||
|
key: 'listDevices',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const devices: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.post(`/1/users/validate.json`, {
|
||||||
|
token: $.auth.data.apiToken,
|
||||||
|
user: $.auth.data.userKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data?.devices?.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const device of data.devices) {
|
||||||
|
devices.data.push({
|
||||||
|
value: device,
|
||||||
|
name: device,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return devices;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,30 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List sounds',
|
||||||
|
key: 'listSounds',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const sounds: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
token: $.auth.data.apiToken,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/sounds.json`, { params });
|
||||||
|
const soundEntries = Object.entries(data.sounds);
|
||||||
|
|
||||||
|
for (const [key, value] of soundEntries) {
|
||||||
|
sounds.data.push({
|
||||||
|
value: key,
|
||||||
|
name: value as string,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return sounds;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,5 +1,7 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import actions from './actions';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Pushover',
|
name: 'Pushover',
|
||||||
@@ -11,4 +13,6 @@ export default defineApp({
|
|||||||
primaryColor: '249DF1',
|
primaryColor: '249DF1',
|
||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
auth,
|
auth,
|
||||||
|
actions,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
@@ -266,7 +266,10 @@ export default defineConfig({
|
|||||||
text: 'Pushover',
|
text: 'Pushover',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [{ text: 'Connection', link: '/apps/pushover/connection' }],
|
items: [
|
||||||
|
{ text: 'Actions', link: '/apps/pushover/actions' },
|
||||||
|
{ text: 'Connection', link: '/apps/pushover/connection' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'RSS',
|
text: 'RSS',
|
||||||
|
12
packages/docs/pages/apps/pushover/actions.md
Normal file
12
packages/docs/pages/apps/pushover/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/pushover.svg
|
||||||
|
items:
|
||||||
|
- name: Send a Pushover Notification
|
||||||
|
desc: Generates a Pushover notification on the devices you have subscribed to.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -27,6 +27,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Pipedrive](/apps/pipedrive/triggers)
|
- [Pipedrive](/apps/pipedrive/triggers)
|
||||||
- [Placetel](/apps/placetel/triggers)
|
- [Placetel](/apps/placetel/triggers)
|
||||||
- [PostgreSQL](/apps/postgresql/actions)
|
- [PostgreSQL](/apps/postgresql/actions)
|
||||||
|
- [Pushover](/apps/pushover/actions)
|
||||||
- [RSS](/apps/rss/triggers)
|
- [RSS](/apps/rss/triggers)
|
||||||
- [Salesforce](/apps/salesforce/triggers)
|
- [Salesforce](/apps/salesforce/triggers)
|
||||||
- [Scheduler](/apps/scheduler/triggers)
|
- [Scheduler](/apps/scheduler/triggers)
|
||||||
|
Reference in New Issue
Block a user