From c02abcd86adcae7e145cc79ca93f89226c32bb6d Mon Sep 17 00:00:00 2001 From: NicholasLe04 Date: Sat, 28 Jun 2025 18:03:56 -0700 Subject: [PATCH 1/3] Fix printer healthcheck error handling --- src/APIFunctions/2DPrinting.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/APIFunctions/2DPrinting.js b/src/APIFunctions/2DPrinting.js index d72f911e1..bb4ee3466 100644 --- a/src/APIFunctions/2DPrinting.js +++ b/src/APIFunctions/2DPrinting.js @@ -23,11 +23,7 @@ export async function healthCheck() { const url = new URL('/api/Printer/healthCheck', BASE_API_URL); try { const res = await fetch(url.href); - if (res.ok) { - status.responseData = await res.json(); - } else { - status.error = true; - } + status.error = !!res.ok; } catch (err) { status.responseData = err; status.error = true; From 02cc5174bcce2658a4cef0bd5cf2096b3925cd2a Mon Sep 17 00:00:00 2001 From: NicholasLe04 Date: Sat, 28 Jun 2025 18:08:55 -0700 Subject: [PATCH 2/3] Decimate sendBlastEmail route --- api/cloud_api/routes/Mailer.js | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/api/cloud_api/routes/Mailer.js b/api/cloud_api/routes/Mailer.js index 2fa2561f5..7b512c955 100644 --- a/api/cloud_api/routes/Mailer.js +++ b/api/cloud_api/routes/Mailer.js @@ -129,36 +129,4 @@ router.post('/sendUnsubscribeEmail', async (req, res) => { return res.sendStatus(OK); }); - -// Routing post /sendBlastEmail calls the sendEmail function -// and sends the blast email with the blast email template -router.post('/sendBlastEmail', async (req, res) => { - if (!ENABLED && process.env.NODE_ENV !== 'test') { - return res.sendStatus(OK); - } - const scopes = ['https://mail.google.com/']; - const pathToToken = __dirname + '/../../config/token.json'; - const apiHandler = new SceGoogleApiHandler(scopes, pathToToken); - - await blastEmail( - USER, - req.body.emailList, - req.body.subject, - req.body.content - ) - .then((template) => { - apiHandler - .sendEmail(template) - .then((_) => { - res.sendStatus(OK); - MetricsHandler.emailSent.inc({ type: 'blast' }); - }).catch((_) => { - res.sendStatus(BAD_REQUEST); - }); - }) - .catch((_) => { - res.sendStatus(BAD_REQUEST); - }); -}); - module.exports = router; From dc9704b1104775c5d49ec4ee26e188517efda5fa Mon Sep 17 00:00:00 2001 From: NicholasLe04 Date: Sat, 28 Jun 2025 18:13:52 -0700 Subject: [PATCH 3/3] Remove test for sendBlastEmail route --- test/api/Mailer.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/test/api/Mailer.js b/test/api/Mailer.js index d2f84a731..1422c7ffb 100644 --- a/test/api/Mailer.js +++ b/test/api/Mailer.js @@ -68,25 +68,4 @@ describe('Mailer', () => { expect(result).to.have.status(BAD_REQUEST); }); }); - - describe('/POST sendBlastEmail', () => { - it('Should return 200 when an email is successfully sent', async () => { - sendEmailStub.resolves({}); - verificationStub.resolves({}); - const result = await test.sendPostRequest( - '/api/Mailer/sendBlastEmail', - VALID_EMAIL_REQUEST - ); - expect(result).to.have.status(OK); - }); - - it('Should return 400 when sending an email fails', async () => { - sendEmailStub.rejects({}); - const result = await test.sendPostRequest( - '/api/Mailer/sendBlastEmail', - VALID_EMAIL_REQUEST - ); - expect(result).to.have.status(BAD_REQUEST); - }); - }); });