Skip to content

Commit

Permalink
Merge pull request #7733 from opengovsg/fix/ses-default
Browse files Browse the repository at this point in the history
fix: ses default configset
  • Loading branch information
kevin9foong authored Sep 27, 2024
2 parents ec58886 + f4c78cb commit 422fbff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ const mailConfig: MailConfig = (function () {
official,
mailer,
transporter,
sesConfigSet: prodOnlyVars.sesConfigSet,
}
})()

Expand Down
7 changes: 7 additions & 0 deletions src/app/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ export const prodOnlyVarsSchema: Schema<IProdOnlyVarsSchema> = {
env: 'SES_PASS',
sensitive: true,
},
sesConfigSet: {
doc: 'Config set for SES when sending email',
format: String,
default: null,
env: 'SES_CONFIG_SET',
sensitive: true,
},
dbHost: {
doc: 'Database URI',
format: (val) => {
Expand Down
19 changes: 15 additions & 4 deletions src/app/services/mail/mail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,21 @@ export class MailService {
}

return ResultAsync.fromPromise(
this.#sendMailWithRetries(mail, {
mailId: sendOptions?.mailId,
formId: sendOptions?.formId,
}),
this.#sendMailWithRetries(
{
...mail,
headers: config.mail.sesConfigSet
? {
'X-SES-CONFIGURATION-SET': config.mail.sesConfigSet,
...mail.headers,
}
: mail.headers,
},
{
mailId: sendOptions?.mailId,
formId: sendOptions?.formId,
},
),
(error) => {
logger.error({
message: 'Error returned from sendMail retries',
Expand Down
2 changes: 2 additions & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type MailConfig = {
}
official: string
transporter: Mail
sesConfigSet: string
}

export type RateLimitConfig = {
Expand Down Expand Up @@ -121,6 +122,7 @@ export interface IProdOnlyVarsSchema {
user: string
pass: string
dbHost: string
sesConfigSet: string
}

export interface ICompulsoryVarsSchema {
Expand Down

0 comments on commit 422fbff

Please sign in to comment.