mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 13:27:38 +00:00
103d96dc81
Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
import {Config} from '../config';
|
|
import {sendEmail} from './email';
|
|
import {sendSMS} from './sms';
|
|
import {playSound} from './sound';
|
|
import {sendSlackMessage} from './slack';
|
|
import {sendPushoverNotification} from './pushover';
|
|
import {sendTelegramMessage} from './telegram';
|
|
|
|
const notifications = Config.notifications;
|
|
|
|
export function sendNotification(cartUrl: string) {
|
|
if (notifications.email.username && notifications.email.password) {
|
|
sendEmail(cartUrl);
|
|
}
|
|
|
|
if (notifications.slack.channel && notifications.slack.token) {
|
|
sendSlackMessage(cartUrl);
|
|
}
|
|
|
|
if (notifications.telegram.accessToken && notifications.telegram.chatId) {
|
|
sendTelegramMessage(cartUrl);
|
|
}
|
|
|
|
if (notifications.phone.number) {
|
|
const carrier = notifications.phone.carrier.toLowerCase();
|
|
if (carrier && notifications.phone.availableCarriers.has(carrier)) {
|
|
sendSMS(cartUrl);
|
|
}
|
|
}
|
|
|
|
if (notifications.pushover.token && notifications.pushover.user) {
|
|
sendPushoverNotification(cartUrl);
|
|
}
|
|
|
|
if (notifications.playSound) {
|
|
playSound();
|
|
}
|
|
}
|