Skip to content

Commit

Permalink
[Components] ntfy - Send Notification action (#14578)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes authored Nov 8, 2024
1 parent 5561c97 commit ac0a92f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 8 deletions.
56 changes: 56 additions & 0 deletions components/ntfy/actions/send-notification/send-notification.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import app from "../../ntfy.app.mjs";

export default {
key: "ntfy-send-notification",
name: "Send Notification",
description: "Send a notification using Ntfy. [See the documentation](https://docs.ntfy.sh/publish/).",
version: "0.0.1",
type: "action",
props: {
app,
topic: {
type: "string",
label: "Topic",
description: "The topic to which the notification will be sent",
},
data: {
type: "string",
label: "Message",
description: "The message content of the notification",
},
headers: {
type: "object",
label: "Headers",
description: "Optional headers to include in the request. [See the documentation](https://docs.ntfy.sh/publish/).",
optional: true,
},
},
methods: {
sendNotification({
topic, ...args
} = {}) {
return this.app.post({
path: `/${topic}`,
...args,
});
},
},
async run({ $ }) {
const {
sendNotification,
topic,
data,
headers,
} = this;

const response = await sendNotification({
$,
headers,
topic,
data,
});

$.export("$summary", `Successfully sent notification with ID \`${response.id}\`.`);
return response;
},
};
24 changes: 19 additions & 5 deletions components/ntfy/ntfy.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "ntfy",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
getUrl(path) {
return `${this.$auth.server}${path}`;
},
_makeRequest({
$ = this, path, ...args
} = {}) {
return axios($, {
...args,
url: this.getUrl(path),
});
},
post(args = {}) {
return this._makeRequest({
method: "POST",
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/ntfy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/ntfy",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream ntfy Components",
"main": "ntfy.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "3.0.3"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ac0a92f

Please sign in to comment.