feat(notification): add desktop notifications (#140)

Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Nachi G
2020-09-20 17:48:27 -07:00
committed by GitHub
parent 7191e03a80
commit 722eaf3cd6
6 changed files with 123 additions and 5 deletions
+1
View File
@@ -13,6 +13,7 @@ const browser = {
const logLevel = process.env.LOG_LEVEL ?? 'info';
const notifications = {
desktop: process.env.DESKTOP_NOTIFICATIONS === 'true',
discord: {
notifyGroup: process.env.DISCORD_NOTIFY_GROUP ?? '',
webHookUrl: process.env.DISCORD_WEB_HOOK ?? ''
+14
View File
@@ -0,0 +1,14 @@
import notifier from 'node-notifier';
import {Link} from '../store/model';
export function sendDesktopNotification(cartUrl: string, link: Link) {
(async () => {
const title = link.brand + ' ' + link.model + ' IN STOCK';
const message = cartUrl;
notifier.notify({
title,
message
});
})();
}
+6
View File
@@ -6,6 +6,8 @@ import {sendSlackMessage} from './slack';
import {sendPushoverNotification} from './pushover';
import {sendTelegramMessage} from './telegram';
import {sendDiscordMessage} from './discord';
import {sendDesktopNotification} from './desktop';
import {Link} from '../store/model';
const notifications = Config.notifications;
@@ -41,4 +43,8 @@ export function sendNotification(cartUrl: string, link: Link) {
if (notifications.playSound) {
playSound();
}
if (notifications.desktop) {
sendDesktopNotification(cartUrl, link);
}
}