feat(notification): add product link to email and telegram (#816)

This commit is contained in:
VictorV
2020-11-18 07:23:31 -08:00
committed by GitHub
parent 229daabb34
commit 777c31b420
3 changed files with 9 additions and 3 deletions
+6
View File
@@ -180,6 +180,12 @@ export const Print = {
return `${buildProductString(link, store)} :: OUT OF STOCK`;
},
productInStock(link: Link): string {
let productString = `Product Page: ${link.url}`;
if (link.cartUrl) productString += `\nAdd To Cart Link: ${link.cartUrl}`;
return productString;
},
rateLimit(link: Link, store: Store, color?: boolean): string {
if (color) {
return (
+1 -1
View File
@@ -40,7 +40,7 @@ export function sendEmail(link: Link, store: Store) {
: undefined,
from: email.username,
subject: Print.inStock(link, store),
text: link.cartUrl ? link.cartUrl : link.url,
text: Print.productInStock(link),
to: email.to
};
+2 -2
View File
@@ -14,7 +14,7 @@ export function sendTelegramMessage(link: Link, store: Store) {
logger.debug('↗ sending telegram message');
(async () => {
const givenUrl = link.cartUrl ? link.cartUrl : link.url;
const message = Print.productInStock(link);
const results = [];
for (const chatId of telegram.chatId) {
@@ -22,7 +22,7 @@ export function sendTelegramMessage(link: Link, store: Store) {
results.push(
client.sendMessage(
chatId,
`${Print.inStock(link, store)}\n${givenUrl}`
`${Print.inStock(link, store)}\n${message}`
)
);
logger.info('✔ telegram message sent');