chore(misc): normalize logs (#242)

This commit is contained in:
Jef LeCompte
2020-09-23 14:20:06 -04:00
committed by GitHub
parent 8466f9f398
commit 7c50e2b5aa
21 changed files with 239 additions and 183 deletions
+37 -26
View File
@@ -1,5 +1,6 @@
import {Link, Store} from '../store/model';
import {Config} from '../config';
import {Link} from '../store/model';
import {Logger} from '../logger';
import {playSound} from './sound';
import {sendDesktopNotification} from './desktop';
import {sendDiscordMessage} from './discord';
@@ -13,44 +14,53 @@ import {sendTweet} from './twitter';
const notifications = Config.notifications;
export function sendNotification(cartUrl: string, link: Link) {
export function sendNotification(link: Link, store: Store) {
if (notifications.email.username && notifications.email.password) {
sendEmail(cartUrl, link);
}
if (notifications.slack.channel && notifications.slack.token) {
sendSlackMessage(cartUrl);
}
if (notifications.telegram.accessToken && notifications.telegram.chatId) {
sendTelegramMessage(cartUrl);
}
if (notifications.discord.webHookUrl) {
sendDiscordMessage(cartUrl, link);
Logger.debug('↗ sending email');
sendEmail(link, store);
}
if (notifications.phone.number) {
Logger.debug('↗ sending sms');
const carrier = notifications.phone.carrier.toLowerCase();
if (carrier && notifications.phone.availableCarriers.has(carrier)) {
sendSMS(cartUrl, link);
sendSMS(link, store);
}
}
if (notifications.pushBulletApiKey) {
sendPushBulletNotification(cartUrl, link);
}
if (notifications.pushover.token && notifications.pushover.username) {
sendPushoverNotification(cartUrl);
}
if (notifications.playSound) {
Logger.debug('↗ playing sound');
playSound();
}
if (notifications.desktop) {
sendDesktopNotification(cartUrl, link);
Logger.debug('↗ sending desktop notification');
sendDesktopNotification(link, store);
}
if (notifications.discord.webHookUrl) {
Logger.debug('↗ sending discord message');
sendDiscordMessage(link, store);
}
if (notifications.slack.channel && notifications.slack.token) {
Logger.debug('↗ sending slack message');
sendSlackMessage(link, store);
}
if (notifications.telegram.accessToken && notifications.telegram.chatId) {
Logger.debug('↗ sending telegram message');
sendTelegramMessage(link, store);
}
if (notifications.pushBulletApiKey) {
Logger.debug('↗ sending pushbullet message');
sendPushBulletNotification(link, store);
}
if (notifications.pushover.token && notifications.pushover.username) {
Logger.debug('↗ sending pushover message');
sendPushoverNotification(link, store);
}
if (
@@ -59,6 +69,7 @@ export function sendNotification(cartUrl: string, link: Link) {
notifications.twitter.consumerKey &&
notifications.twitter.consumerSecret
) {
sendTweet(cartUrl, link);
Logger.debug('↗ sending twitter message');
sendTweet(link, store);
}
}