refactor: lookup, rm defaults (#69)

prep work for #38

Signed-off-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Jef LeCompte
2020-09-19 12:45:03 -04:00
committed by GitHub
parent 3b2ba29cf1
commit ea5b7a0918
19 changed files with 142 additions and 134 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ const mailOptions: Mail.Options = {
subject
};
export default function sendEmail(text: string) {
export function sendEmail(text: string) {
mailOptions.text = text;
transporter.sendMail(mailOptions, (error, info) => {
+1 -26
View File
@@ -1,26 +1 @@
import {Config} from '../config';
import sendEmail from './email';
import sendSlaskMessage from './slack';
import sendSMS from './sms';
import playSound from './sound';
export default function sendNotification(cartUrl: string) {
if (Config.notifications.email.username && Config.notifications.email.password) {
sendEmail(cartUrl);
}
if (Config.notifications.slack.channel && Config.notifications.slack.token) {
sendSlaskMessage(cartUrl);
}
if (Config.notifications.phone.number) {
const carrier = Config.notifications.phone.carrier.toLowerCase();
if (carrier && Config.notifications.phone.availableCarriers.has(carrier)) {
sendSMS(cartUrl);
}
}
if (Config.notifications.playSound) {
playSound();
}
}
export * from './notification';
+26
View File
@@ -0,0 +1,26 @@
import {Config} from '../config';
import {sendEmail} from './email';
import {sendSMS} from './sms';
import {playSound} from './sound';
import {sendSlackMessage} from './slack';
export function sendNotification(cartUrl: string) {
if (Config.notifications.email.username && Config.notifications.email.password) {
sendEmail(cartUrl);
}
if (Config.notifications.slack.channel && Config.notifications.slack.token) {
sendSlackMessage(cartUrl);
}
if (Config.notifications.phone.number) {
const carrier = Config.notifications.phone.carrier.toLowerCase();
if (carrier && Config.notifications.phone.availableCarriers.has(carrier)) {
sendSMS(cartUrl);
}
}
if (Config.notifications.playSound) {
playSound();
}
}
+1 -1
View File
@@ -6,7 +6,7 @@ const channel = Config.notifications.slack.channel;
const token = Config.notifications.slack.token;
const web = new WebClient(token);
export default function sendSlackMessage(text: string) {
export function sendSlackMessage(text: string) {
(async () => {
try {
const result = await web.chat.postMessage({text, channel});
+1 -1
View File
@@ -20,7 +20,7 @@ const mailOptions: Mail.Options = {
subject
};
export default function sendSMS(text: string) {
export function sendSMS(text: string) {
mailOptions.text = text;
transporter.sendMail(mailOptions, (error, info) => {
+1 -1
View File
@@ -6,7 +6,7 @@ import * as fs from 'fs';
const notificationSound = './resources/sounds/' + Config.notifications.playSound;
const player = playerLib();
export default function playSound() {
export function playSound() {
// Check if file exists
fs.access(notificationSound, fs.constants.F_OK, err => {
if (err) {