Skip to content

Commit

Permalink
Return strict boolean from email service
Browse files Browse the repository at this point in the history
  • Loading branch information
trslater committed May 7, 2024
1 parent 73224d4 commit ec6143e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,15 @@ export class NotificationSubmissionService {
): Promise<boolean> {
const templateData = await this.generateSrwEmailData(submission, document);

const didSend =
(await this.emailService.sendEmail({
to: [templateData.to],
body: templateData.html,
subject: `Agricultural Land Commission SRW${submission.fileNumber} (${submission.applicant})`,
parentType: PARENT_TYPE.NOTIFICATION,
parentId: templateData.parentId,
cc: templateData.cc,
attachments: [document.document],
})) ?? false;
const didSend = await this.emailService.sendEmail({
to: [templateData.to],
body: templateData.html,
subject: `Agricultural Land Commission SRW${submission.fileNumber} (${submission.applicant})`,
parentType: PARENT_TYPE.NOTIFICATION,
parentId: templateData.parentId,
cc: templateData.cc,
attachments: [document.document],
});

if (didSend) {
const fileBuffer = Buffer.from(templateData.html);
Expand Down
4 changes: 2 additions & 2 deletions services/apps/alcs/src/providers/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class EmailService {
parentId?: string;
triggerStatus?: string;
attachments?: Document[];
}) {
}): Promise<boolean> {
const serviceUrl = this.config.get<string>('CHES.URL');
const from = this.config.get<string>('CHES.FROM');
const token = await this.getToken();
Expand Down Expand Up @@ -134,7 +134,7 @@ export class EmailService {
{ to, body, subject, cc, bcc },
'EmailService did not send the email. Set CHES.MODE to production if you need to send an email.',
);
return;
return false;
}
const res = await firstValueFrom(
this.httpService.post<{
Expand Down

0 comments on commit ec6143e

Please sign in to comment.