From e2303fac36d8719e227c90d316092a486b3450eb Mon Sep 17 00:00:00 2001 From: pratishta Date: Thu, 5 Dec 2024 11:46:11 -0500 Subject: [PATCH] Use email to send modify subscription email --- server/src/subscriber/subscriber.controller.ts | 18 +++++++----------- server/src/subscriber/subscriber.service.ts | 3 +-- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/server/src/subscriber/subscriber.controller.ts b/server/src/subscriber/subscriber.controller.ts index 0491d0b7..7db4fd12 100644 --- a/server/src/subscriber/subscriber.controller.ts +++ b/server/src/subscriber/subscriber.controller.ts @@ -123,8 +123,8 @@ export class SubscriberController { response.send(updatedContact); } - @Get("/subscribers/:email/modify") - async modifySubscriptions(@Req() request: Request, @Param() params, @Res() response) { + @Post("/subscribers/:email/modify") + async modifySubscriptions(@Param() params, @Res() response) { const existingUser = await this.subscriberService.findByEmail(params.email); if (existingUser.code === 404) { response.status(404).send({ @@ -135,15 +135,11 @@ export class SubscriberController { const userId = existingUser['1'].result[params.email].contact.custom_fields[`zap_${this.sendgridEnvironment}_id`]; - // const email = await this.subscriberService.getUserById(id); - // if (email.isError) { - // response.status(email.code).send({ errors: email.response.body.errors }) - // return; - // } - - // Send the confirmation email + // Send the modify email await this.subscriberService.sendModifySubscriptionEmail(params.email, this.sendgridEnvironment, userId); - - // return; + response.status(201).send({ + message: "Modify subscription email sent" + }); + return; } } \ No newline at end of file diff --git a/server/src/subscriber/subscriber.service.ts b/server/src/subscriber/subscriber.service.ts index dae326d7..5ed95dad 100644 --- a/server/src/subscriber/subscriber.service.ts +++ b/server/src/subscriber/subscriber.service.ts @@ -181,10 +181,9 @@ export class SubscriberService { } /** - * Send the user an email requesting signup confirmation. + * Send the user an email to modify their subscriptions. * @param {string} email - The user's email address * @param {string} environment - Staging or production - * @param {object} subscriptions - The CDs the user is subscribing to * @param {string} id - The id needed for confirmation * @returns {object} */