Update flow
This commit is contained in:
parent
c3ac1a81ab
commit
d127dc9d5a
17
src/index.js
17
src/index.js
|
|
@ -189,8 +189,10 @@ async function notifyTelegram(message) {
|
|||
);
|
||||
// console.log(message);
|
||||
console.log('✓ Telegram notification sent');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('✗ Failed to send Telegram notification:', error.response?.data || error.message);
|
||||
console.log('error to send:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +219,7 @@ async function checkAndNotify(keyword, marketplace = "EBAY_US") {
|
|||
const priceInUSD = await convertToUSD(parseFloat(item.price || 0), item.currency);
|
||||
if (priceInUSD < PRICE_THRESHOLD) {
|
||||
cheapItems.push({ ...item, priceInUSD });
|
||||
addToNotified(item.legacyItemId);
|
||||
// addToNotified(item.legacyItemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +232,12 @@ async function checkAndNotify(keyword, marketplace = "EBAY_US") {
|
|||
).join('\n==================================\n') +
|
||||
'\n==================================';
|
||||
|
||||
await notifyTelegram(message);
|
||||
const flag = await notifyTelegram(message);
|
||||
if (flag) {
|
||||
cheapItems.forEach(item => {
|
||||
addToNotified(item.legacyItemId);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log(`No items found below $${PRICE_THRESHOLD} USD`);
|
||||
}
|
||||
|
|
@ -264,11 +271,11 @@ app.post('/check', express.json(), async (req, res) => {
|
|||
const EBAY_SEARCH_CONFIGS = [
|
||||
{
|
||||
marketplace: "EBAY_US",
|
||||
q: "MACBOOK PRO M1 32GB",
|
||||
q: `macbook "pro" "m1" "32gb"`,
|
||||
},
|
||||
{
|
||||
marketplace: "EBAY_AU",
|
||||
q: "MACBOOK PRO M1 32GB",
|
||||
q: `macbook "pro" "m1" "32gb"`,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue