Skip to content

Commit 72cffb2

Browse files
CCM-10283: Fix CI
1 parent a8e0a07 commit 72cffb2

File tree

5 files changed

+35
-30
lines changed

5 files changed

+35
-30
lines changed

infrastructure/terraform/components/sandbox/ses_receipt_rule.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "aws_ses_receipt_rule" "main" {
22
name = "${local.csi}-store-email-sandbox"
3-
rule_set_name = local.acct["ses_testing_config"].bucket_name
3+
rule_set_name = local.acct["ses_testing_config"].rule_set_name
44
recipients = [local.sandbox_letter_supplier_mock_recipient]
55
enabled = true
66
scan_enabled = true

lambdas/backend-api/src/templates/infra/email-client.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createMimeMessage } from 'mimetext';
1+
import { createMimeMessage, MailboxAddrObject } from 'mimetext';
22
import { SESClient, SendRawEmailCommand } from '@aws-sdk/client-ses';
33
import { TemplateDto } from 'nhs-notify-backend-client';
44
import { Logger } from 'nhs-notify-web-template-management-utils/logger';
@@ -42,9 +42,11 @@ export class EmailClient {
4242

4343
const msg = createMimeMessage();
4444
msg.setSender({ name: 'NHS Notify', addr: this.senderEmail });
45-
msg.setBcc(
46-
recipientEmailsForSupplier.map((emailAddress) => ({ addr: emailAddress }))
45+
46+
const recipients: MailboxAddrObject[] = recipientEmailsForSupplier.map(
47+
(emailAddress) => ({ addr: emailAddress, type: 'Bcc' })
4748
);
49+
msg.setTo(recipients);
4850
msg.setSubject(`${supplier} - Letter proof approved by an NHS Notify user`);
4951
msg.addMessage({
5052
contentType: 'text/html',

lambdas/backend-api/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
2-
"extends": "@tsconfig/node20/tsconfig.json",
32
"compilerOptions": {
3+
"isolatedModules": true,
4+
"moduleResolution": "node16",
45
"paths": {
56
"@backend-api/templates/*": [
67
"./src/templates/*"
@@ -9,9 +10,9 @@
910
"./src/utils/*"
1011
]
1112
},
12-
"resolveJsonModule": true,
13-
"isolatedModules": true
13+
"resolveJsonModule": true
1414
},
15+
"extends": "@tsconfig/node20/tsconfig.json",
1516
"include": [
1617
"src/**/*",
1718
"scripts/generate-dependencies.ts"

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test-team/helpers/email-helper.ts

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,30 @@ export class EmailHelper {
2424
constructor() {}
2525

2626
async getAllS3Items() {
27-
const command = new ListObjectsV2Command({
28-
Bucket: this.testEmailBucketName,
29-
Prefix: this.testEmailPrefix,
30-
});
31-
32-
const { Contents = [], ContinuationToken } = await this.s3Client.send(command);
27+
const { Contents = [], ContinuationToken } = await this.s3Client.send(
28+
new ListObjectsV2Command({
29+
Bucket: this.testEmailBucketName,
30+
Prefix: this.testEmailPrefix,
31+
})
32+
);
3333

3434
let nextToken = ContinuationToken;
3535
let s3Items = Contents;
3636

3737
while (nextToken) {
38-
const command = new ListObjectsV2Command({
39-
Bucket: this.testEmailBucketName,
40-
Prefix: this.testEmailPrefix,
41-
ContinuationToken: nextToken,
42-
});
43-
44-
const { Contents = [], ContinuationToken } = await this.s3Client.send(command);
45-
46-
s3Items = [...s3Items, ...Contents];
47-
nextToken = ContinuationToken;
38+
const {
39+
Contents: newContents = [],
40+
ContinuationToken: newContinuationToken,
41+
} = await this.s3Client.send(
42+
new ListObjectsV2Command({
43+
Bucket: this.testEmailBucketName,
44+
Prefix: this.testEmailPrefix,
45+
ContinuationToken: nextToken,
46+
})
47+
);
48+
49+
s3Items = [...s3Items, ...newContents];
50+
nextToken = newContinuationToken;
4851
}
4952

5053
return s3Items;
@@ -53,12 +56,12 @@ export class EmailHelper {
5356
async getEmailForTemplateId(templateId: string, dateCutoff: Date) {
5457
const s3Items = await this.getAllS3Items();
5558

56-
const sortedKeys = s3Items.filter(
57-
({ LastModified }) => (LastModified ?? 0) > dateCutoff
58-
).sort(
59-
(a, b) =>
60-
(b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0)
61-
);
59+
const sortedKeys = s3Items
60+
.filter(({ LastModified }) => (LastModified ?? 0) > dateCutoff)
61+
.sort(
62+
(a, b) =>
63+
(b.LastModified?.getTime() ?? 0) - (a.LastModified?.getTime() ?? 0)
64+
);
6265

6366
// SES does not tell us what the S3 keys are going to be for received emails,
6467
// so we have to search all recent ones to ensure we get the right one and

0 commit comments

Comments
 (0)