Skip to content

Commit

Permalink
Dealing with issues from merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhochbaum-dcp committed Oct 31, 2024
1 parent fcbb68a commit ab76675
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 4 additions & 2 deletions server/src/subscriber/subscriber.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ export class SubscriberController {
const importConfirmation = await this.subscriberService.checkCreate(addToQueue.result[1]["job_id"], response, 0, CHECKS_BEFORE_FAIL, PAUSE_BETWEEN_CHECKS, errorInfo);

// Send the confirmation email
await this.subscriberService.sendConfirmationEmail(request.body.email, this.sendgridEnvironment, request.body.subscriptions, id)

if (!importConfirmation.isError) {
await this.subscriberService.sendConfirmationEmail(request.body.email, this.sendgridEnvironment, request.body.subscriptions, id);
}

return;

}
Expand Down
35 changes: 34 additions & 1 deletion server/src/subscriber/subscriber.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export class SubscriberService {

const confirmationRequest = {
url: `/v3/marketing/contacts/imports/${importId}`,
// method:<HttpMethod> 'GET',
method:<HttpMethod> 'GET',
}

Expand Down Expand Up @@ -216,4 +215,38 @@ export class SubscriberService {
return validCustomFieldValues.includes(value as CustomFieldValue);
}

/**
* Convert the uploaded subscriptions object into a format for Handlebars to use in the confirmation email
* @param {object} subscriptions - The set of CDs the user is subscribing to
* @returns {boolean}
*/
private convertSubscriptionsToHandlebars(subscriptions: object) {
var handlebars = { "citywide": false, "boroughs": [] }
const boros = {
"K": "Brooklyn",
"X": "Bronx",
"M": "Manhattan",
"Q": "Queens",
"R": "Staten Island"
}
for (const [key, value] of Object.entries(subscriptions)) {
if (value === 1) {
if (key === "CW") {
handlebars.citywide = true;
} else if (boros[key[0]]) {
const i = handlebars.boroughs.findIndex((boro) => boro.name === boros[key[0]]);
if (i === -1) {
handlebars.boroughs.push({
"name": boros[key[0]],
"communityBoards": [parseInt(key.slice(-2))]
})
} else {
handlebars.boroughs[i]["communityBoards"].push(parseInt(key.slice(-2)))
}
}
}
}
return handlebars;
}

}

0 comments on commit ab76675

Please sign in to comment.