From e5ea735a3d4791e6c2ab7178af9d603b31ea1f5e Mon Sep 17 00:00:00 2001 From: nguyentrungthat <80239428+nguentrungthat@users.noreply.github.com> Date: Wed, 22 Oct 2025 11:28:07 +0700 Subject: [PATCH] Update index.js --- index.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 68998a4..43c47b4 100644 --- a/index.js +++ b/index.js @@ -166,7 +166,7 @@ async function scrapeWithCheerio(url) { return items; } -async function sendMail(subject, body, isError = false) { +async function sendMail(subject, body) { try { await axios({ url: process.env.API_DISTI_HOST + "/api/export/items-sold-out", @@ -201,14 +201,12 @@ async function sendMail(subject, body, isError = false) { to: EMAILS.join(","), subject, text: body, - attachments: isError - ? [] - : [ - { - filename: fileName, - content: response.data, // attach from memory - }, - ], + attachments: [ + { + filename: fileName, + content: response.data, // attach from memory + }, + ], }; await transporter.sendMail(mailOptions); @@ -270,7 +268,7 @@ async function main() { if (errors.length > 3) { const msg = errors.map((e) => `URL: ${e.url}\nMessage: ${e.message}`).join("\n\n"); - await sendMail("[New Items] - Scraping Sold Out Error Report", msg, true); + await sendMail("[New Items] - Scraping Sold Out Error Report", msg); } else { const msg = inserted.map((i) => `Shop: ${i.name}\nSold: ${i.count} items`).join("\n\n"); await sendMail("[New Items] - Scraping Sold Out Success", msg);