From 2a28e5dc8c85726fcaa88e25e786b84270a6c55f Mon Sep 17 00:00:00 2001 From: Kar Rui Lau Date: Mon, 28 Feb 2022 22:38:13 +0800 Subject: [PATCH] feat(BounceController): log SNS topic confirmation notification emails --- src/app/modules/bounce/bounce.controller.ts | 11 +++++++++++ .../api/v3/notifications/bounces/bounces.routes.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/modules/bounce/bounce.controller.ts b/src/app/modules/bounce/bounce.controller.ts index 404cd59568..d15ac91ec9 100644 --- a/src/app/modules/bounce/bounce.controller.ts +++ b/src/app/modules/bounce/bounce.controller.ts @@ -23,6 +23,17 @@ export const handleSns: ControllerHandler< never, ISnsNotification > = async (req, res) => { + if (req.get('x-amz-sns-message-type') === 'SubscriptionConfirmation') { + logger.info({ + meta: { + action: 'handleSns', + body: req.body, + }, + message: 'Handling SNS topic confirmation notification', + }) + return res.sendStatus(StatusCodes.OK) + } + const notificationResult = await BounceService.validateSnsRequest( req.body, ).andThen(() => BounceService.safeParseNotification(req.body.Message)) diff --git a/src/app/routes/api/v3/notifications/bounces/bounces.routes.ts b/src/app/routes/api/v3/notifications/bounces/bounces.routes.ts index 065481c8a3..623ad0a21b 100644 --- a/src/app/routes/api/v3/notifications/bounces/bounces.routes.ts +++ b/src/app/routes/api/v3/notifications/bounces/bounces.routes.ts @@ -11,6 +11,6 @@ export const BouncesRouter = Router() * Note that if anything errors in between, just return a 200 * to SNS, as the error code to them doesn't really matter. * - * @route POST /api/v3/notifications/bounce/email + * @route POST /api/v3/notifications/bounces/email */ BouncesRouter.post('/email', handleSns)