-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Apprise notification adapter (#92)
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
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,40 @@ | ||
import { markdown2Html } from '../../services/markdown.js'; | ||
import { getJob } from '../../services/storage/jobStorage.js'; | ||
import fetch from 'node-fetch'; | ||
|
||
export const send = ({ serviceName, newListings, notificationConfig, jobKey }) => { | ||
const { priority, server } = notificationConfig.find((adapter) => adapter.id === config.id).fields; | ||
const job = getJob(jobKey); | ||
const jobName = job == null ? jobKey : job.name; | ||
const promises = newListings.map((newListing) => { | ||
const message = `Address: ${newListing.address}\nSize: ${newListing.size}\nPrice: ${newListing.price}\nURL: ${newListing.link}`; | ||
return fetch(server, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | ||
body: message, | ||
title: newListing.title, | ||
}), | ||
}); | ||
}); | ||
|
||
return Promise.all(promises); | ||
}; | ||
export const config = { | ||
id: 'apprise', | ||
name: 'Apprise', | ||
readme: markdown2Html('lib/notification/adapter/apprise.md'), | ||
description: 'Fredy will send new listings to your Apprise instance.', | ||
fields: { | ||
priority: { | ||
type: 'number', | ||
label: 'Priority', | ||
description: 'The priority of the send notification.', | ||
}, | ||
server: { | ||
type: 'text', | ||
label: 'Server', | ||
description: 'The server url to send the notification to.', | ||
}, | ||
}, | ||
}; |
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,5 @@ | ||
### Apprise Adapter | ||
|
||
Refer to the [instructions](https://github.com/caronc/apprise-api#installation) on how to set up an Apprise instance and how to configure your preferred notification service. | ||
|
||
In addition to the Apprise instance, the priority must be defined. |