feat(notification): add pushbullet, add url with notifications (#226)

Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
fuckingrobot
2020-09-23 10:45:04 -04:00
committed by GitHub
parent 20656805c1
commit 74490eae3a
11 changed files with 106 additions and 8 deletions
+5
View File
@@ -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);
}
+19
View File
@@ -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}`);
}
});
}