mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 06:27:38 +00:00
feat(notification): add desktop notifications (#140)
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
@@ -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 ?? ''
|
||||
|
||||
@@ -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,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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user