Skip to content

Commit

Permalink
Use email to send modify subscription email
Browse files Browse the repository at this point in the history
  • Loading branch information
pratishta authored and TylerMatteo committed Dec 6, 2024
1 parent 0c2aa24 commit e2303fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
18 changes: 7 additions & 11 deletions server/src/subscriber/subscriber.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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;
}
}
3 changes: 1 addition & 2 deletions server/src/subscriber/subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
*/
Expand Down

0 comments on commit e2303fa

Please sign in to comment.