Skip to content

Commit 2d6817f

Browse files
Merge pull request #1232 from con2/feature/email-html-body
Add html body to email messages
2 parents 3319061 + 32faf8f commit 2d6817f

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

server/src/features/assignment/utils/saveUserSignupResults.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Terveisin / Sincerely Konsti`;
221221
const expectedAcceptedSubject =
222222
"Konstiarvonnan tulos / Results for Konsti lottery signup";
223223
const expectedRejectedBody = `Hei ${mockUser2.username}!
224-
Et valitettavasti päässyt arvonnassa yhteenkaan ohjelmaan johon ilmoittauduit.
224+
Et valitettavasti päässyt arvonnassa yhteenkään ohjelmaan johon ilmoittauduit.
225225
226226
Hi Test User 2!
227227
Unfortunately you did not get spot on lottery signup.

server/src/features/notifications/emailNotificationWorker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ async function generateAcceptedEmail(
8787

8888
const subject = getEmailSubjectAccepted();
8989
const body = getEmailBodyAccepted(program.title, notification);
90+
const htmlBody = body.replaceAll("\n", "<br />");
9091
return {
9192
from: fromAddress,
9293
to: email,
9394
subject,
9495
text: body,
96+
html: `<p>${htmlBody}</p>`,
9597
};
9698
}
9799

@@ -102,10 +104,12 @@ function generateRejectedEmail(
102104
): EmailMessage {
103105
const subject = getEmailSubjectRejected();
104106
const body = getEmailBodyRejected(notification);
107+
const htmlBody = body.replaceAll("\n", "<br />");
105108
return {
106109
from: fromAddress,
107110
to: email,
108111
subject,
109112
text: body,
113+
html: `<p>${htmlBody}</p>`,
110114
};
111115
}

server/src/features/notifications/senderCommon.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function getEmailSubjectAccepted(): string {
2222

2323
export function getEmailBodyRejected(notification: NotificationTask): string {
2424
const bodyFi = `Hei ${notification.username}!
25-
Et valitettavasti päässyt arvonnassa yhteenkaan ohjelmaan johon ilmoittauduit.`;
25+
Et valitettavasti päässyt arvonnassa yhteenkään ohjelmaan johon ilmoittauduit.`;
2626
const bodyEn = `Hi ${notification.username}!
2727
Unfortunately you did not get spot on lottery signup.`;
2828
return `${bodyFi}\n\n${bodyEn}\n\nTerveisin / Sincerely Konsti`;

0 commit comments

Comments
 (0)