From 3940eddbbbf26c86eaa645327442b0e004d4fa2a Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 3 Nov 2023 16:38:19 +0100 Subject: [PATCH] fix(api): trim trailing space if no reporter name (#52199) --- api/src/routes/user.test.ts | 12 +++++++----- api/src/utils/email-templates.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/src/routes/user.test.ts b/api/src/routes/user.test.ts index be02f2cd9b1..2bd37348a54 100644 --- a/api/src/routes/user.test.ts +++ b/api/src/routes/user.test.ts @@ -723,9 +723,11 @@ describe('userRoutes', () => { }); test('POST returns 200 status code with "success" message', async () => { - const testUser = await fastifyTestInstance.prisma.user.findFirst({ - where: { email: testUserData.email } - }); + const testUser = await fastifyTestInstance.prisma.user.findFirstOrThrow( + { + where: { email: testUserData.email } + } + ); const response = await superRequest('/user/report-user', { method: 'POST', setCookies @@ -751,8 +753,8 @@ Luke, I am your father Reported by: -Username: ${testUser?.username ?? ''} -Name: +Username: ${testUser.username} +Name: Email: foo@bar.com Thanks and regards, diff --git a/api/src/utils/email-templates.ts b/api/src/utils/email-templates.ts index b7d73c566b6..31373c59ec9 100644 --- a/api/src/utils/email-templates.ts +++ b/api/src/utils/email-templates.ts @@ -24,7 +24,7 @@ ${reportDesc} Reported by: Username: ${reporter.username} -Name: ${reporter.name ?? ''} +Name:${reporter.name ? ' ' + reporter.name : ''} Email: ${reporter.email} Thanks and regards,