-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Components] ntfy - Send Notification action (#14578)
- Loading branch information
Showing
4 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
components/ntfy/actions/send-notification/send-notification.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "3.0.3" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.