mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 15:47:35 +00:00
chore(misc): normalize logs (#242)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user