mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 15:47:35 +00:00
chore: move notification test, other refactoring (#111)
This commit is contained in:
@@ -22,7 +22,7 @@ export function sendDiscordMessage(cartUrl: string, link: Link) {
|
||||
embed.setColor(0x76B900);
|
||||
embed.setTimestamp();
|
||||
await hook.send(embed);
|
||||
Logger.info(`✔ discord message sent: ${cartUrl}`);
|
||||
Logger.info(`↗ discord message sent: ${cartUrl}`);
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
@@ -20,15 +20,15 @@ const mailOptions: Mail.Options = {
|
||||
subject
|
||||
};
|
||||
|
||||
export function sendEmail(text: string) {
|
||||
mailOptions.text = text;
|
||||
export function sendEmail(cartUrl: string) {
|
||||
mailOptions.text = cartUrl;
|
||||
|
||||
transporter.sendMail(mailOptions, (error, info) => {
|
||||
if (error) {
|
||||
Logger.error(error);
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
Logger.info(`✔ email sent: ${info.response}`);
|
||||
Logger.info(`↗ email sent: ${info.response}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ const push = new Push({
|
||||
token: pushover.token
|
||||
});
|
||||
|
||||
export function sendPushoverNotification(text: string) {
|
||||
export function sendPushoverNotification(cartUrl: string) {
|
||||
const message = {
|
||||
message: text
|
||||
message: cartUrl
|
||||
};
|
||||
|
||||
push.send(message, (err: Error, result: string) => {
|
||||
if (err) {
|
||||
Logger.error(err);
|
||||
} else {
|
||||
Logger.info(`✔ Pushover notification sent: ${result}`);
|
||||
Logger.info(`↗ pushover notification sent: ${result}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ const channel = Config.notifications.slack.channel;
|
||||
const token = Config.notifications.slack.token;
|
||||
const web = new WebClient(token);
|
||||
|
||||
export function sendSlackMessage(text: string) {
|
||||
export function sendSlackMessage(cartUrl: string) {
|
||||
(async () => {
|
||||
try {
|
||||
const result = await web.chat.postMessage({text, channel});
|
||||
const result = await web.chat.postMessage({text: cartUrl, channel});
|
||||
if (!result.ok) {
|
||||
Logger.error(result.error);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.info(`✔ slack message sent to '${channel}': ${text}`);
|
||||
Logger.info(`↗ slack message sent to '${channel}': ${cartUrl}`);
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export function sendSMS(text: string) {
|
||||
Logger.error(error);
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
Logger.info(`✔ sms sent: ${info.response}`);
|
||||
Logger.info(`↗ sms sent: ${info.response}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export function playSound() {
|
||||
}
|
||||
|
||||
player.play(notificationSound, (err: string) => {
|
||||
Logger.info('✔ playing sound');
|
||||
Logger.info('↗ playing sound');
|
||||
|
||||
if (err) {
|
||||
Logger.error(`error playing sound: ${err}`);
|
||||
|
||||
@@ -12,7 +12,7 @@ export function sendTelegramMessage(text: string) {
|
||||
(async () => {
|
||||
try {
|
||||
await client.sendMessage(telegram.chatId, text);
|
||||
Logger.info(`✔ telegram message sent to '${telegram.chatId}': ${text}`);
|
||||
Logger.info(`↗ telegram message sent to '${telegram.chatId}': ${text}`);
|
||||
} catch (error) {
|
||||
Logger.error(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user