mirror of
https://github.com/opelly27/streetmerchant.git
synced 2026-05-20 06:27:38 +00:00
feat(notification): add product link to email and telegram (#816)
This commit is contained in:
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user