mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 12:17:37 +00:00
feat(notification): add pushbullet, add url with notifications (#226)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import {playSound} from './sound';
|
||||
import {sendDesktopNotification} from './desktop';
|
||||
import {sendDiscordMessage} from './discord';
|
||||
import {sendEmail} from './email';
|
||||
import {sendPushBulletNotification} from './pushbullet';
|
||||
import {sendPushoverNotification} from './pushover';
|
||||
import {sendSMS} from './sms';
|
||||
import {sendSlackMessage} from './slack';
|
||||
@@ -36,6 +37,10 @@ export function sendNotification(cartUrl: string, link: Link) {
|
||||
}
|
||||
}
|
||||
|
||||
if (notifications.pushBulletApiKey) {
|
||||
sendPushBulletNotification(cartUrl, link);
|
||||
}
|
||||
|
||||
if (notifications.pushover.token && notifications.pushover.username) {
|
||||
sendPushoverNotification(cartUrl);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import {Config} from '../config';
|
||||
import {Link} from '../store/model';
|
||||
import {Logger} from '../logger';
|
||||
import PushBullet from 'pushbullet';
|
||||
|
||||
const pushBulletApiKey = Config.notifications.pushBulletApiKey;
|
||||
|
||||
export function sendPushBulletNotification(cartUrl: string, link: Link) {
|
||||
const pusher = new PushBullet(pushBulletApiKey);
|
||||
const title = `🚨 ${link.brand} ${link.model} ${link.series} 👀`;
|
||||
|
||||
pusher.note({}, title, cartUrl, (err: Error, result: string) => {
|
||||
if (err) {
|
||||
Logger.error(err);
|
||||
} else {
|
||||
Logger.info(`↗ pushbullet notification sent: ${result}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user