From bbe1167b97fd269073a712419bfba5cf2be3c32d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:53:25 +0200 Subject: [PATCH] emails are not awaitable anymore --- backend/src/emails/sendEmailVariants.test.ts | 36 +++++++++---------- .../resolver/ContributionMessageResolver.ts | 2 +- .../graphql/resolver/ContributionResolver.ts | 6 ++-- .../graphql/resolver/TransactionResolver.ts | 4 +-- backend/src/graphql/resolver/UserResolver.ts | 12 +++---- 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 44d996fa8..e1f3e7cca 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -50,8 +50,8 @@ describe('sendEmailVariants', () => { let result: any describe('sendAddedContributionMessageEmail', () => { - beforeAll(async () => { - result = await sendAddedContributionMessageEmail({ + beforeAll(() => { + result = sendAddedContributionMessageEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -128,8 +128,8 @@ describe('sendEmailVariants', () => { }) describe('sendAccountActivationEmail', () => { - beforeAll(async () => { - result = await sendAccountActivationEmail({ + beforeAll(() => { + result = sendAccountActivationEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -208,8 +208,8 @@ describe('sendEmailVariants', () => { }) describe('sendAccountMultiRegistrationEmail', () => { - beforeAll(async () => { - result = await sendAccountMultiRegistrationEmail({ + beforeAll(() => { + result = sendAccountMultiRegistrationEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -288,8 +288,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionConfirmedEmail', () => { - beforeAll(async () => { - result = await sendContributionConfirmedEmail({ + beforeAll(() => { + result = sendContributionConfirmedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -368,8 +368,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionDeniedEmail', () => { - beforeAll(async () => { - result = await sendContributionDeniedEmail({ + beforeAll(() => { + result = sendContributionDeniedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -446,8 +446,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionDeletedEmail', () => { - beforeAll(async () => { - result = await sendContributionDeletedEmail({ + beforeAll(() => { + result = sendContributionDeletedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -524,8 +524,8 @@ describe('sendEmailVariants', () => { }) describe('sendResetPasswordEmail', () => { - beforeAll(async () => { - result = await sendResetPasswordEmail({ + beforeAll(() => { + result = sendResetPasswordEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -602,8 +602,8 @@ describe('sendEmailVariants', () => { }) describe('sendTransactionLinkRedeemedEmail', () => { - beforeAll(async () => { - result = await sendTransactionLinkRedeemedEmail({ + beforeAll(() => { + result = sendTransactionLinkRedeemedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -683,8 +683,8 @@ describe('sendEmailVariants', () => { }) describe('sendTransactionReceivedEmail', () => { - beforeAll(async () => { - result = await sendTransactionReceivedEmail({ + beforeAll(() => { + result = sendTransactionReceivedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index a59023036..02e019ea0 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -146,7 +146,7 @@ export class ContributionMessageResolver { await queryRunner.manager.update(DbContribution, { id: contributionId }, contribution) } - void sendAddedContributionMessageEmail({ + sendAddedContributionMessageEmail({ firstName: contribution.user.firstName, lastName: contribution.user.lastName, email: contribution.user.emailContact.email, diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 5969eaef2..1efe9fafa 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -424,7 +424,7 @@ export class ContributionResolver { contribution.amount, ) - void sendContributionDeletedEmail({ + sendContributionDeletedEmail({ firstName: user.firstName, lastName: user.lastName, email: user.emailContact.email, @@ -518,7 +518,7 @@ export class ContributionResolver { await queryRunner.commitTransaction() logger.info('creation commited successfuly.') - void sendContributionConfirmedEmail({ + sendContributionConfirmedEmail({ firstName: user.firstName, lastName: user.lastName, email: user.emailContact.email, @@ -599,7 +599,7 @@ export class ContributionResolver { contributionToUpdate.amount, ) - void sendContributionDeniedEmail({ + sendContributionDeniedEmail({ firstName: user.firstName, lastName: user.lastName, email: user.emailContact.email, diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 0d7d7abf5..a95294f76 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -149,7 +149,7 @@ export const executeTransaction = async ( } finally { await queryRunner.release() } - void sendTransactionReceivedEmail({ + sendTransactionReceivedEmail({ firstName: recipient.firstName, lastName: recipient.lastName, email: recipient.emailContact.email, @@ -160,7 +160,7 @@ export const executeTransaction = async ( transactionAmount: amount, }) if (transactionLink) { - void sendTransactionLinkRedeemedEmail({ + sendTransactionLinkRedeemedEmail({ firstName: sender.firstName, lastName: sender.lastName, email: sender.emailContact.email, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index ba230e6c7..45059a4a7 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -245,7 +245,7 @@ export class UserResolver { user.publisherId = publisherId logger.debug('partly faked user', user) - void sendAccountMultiRegistrationEmail({ + sendAccountMultiRegistrationEmail({ firstName: foundUser.firstName, // this is the real name of the email owner, but just "firstName" would be the name of the new registrant which shall not be passed to the outside lastName: foundUser.lastName, // this is the real name of the email owner, but just "lastName" would be the name of the new registrant which shall not be passed to the outside email, @@ -322,7 +322,7 @@ export class UserResolver { emailContact.emailVerificationCode.toString(), ).replace(/{code}/g, redeemCode ? '/' + redeemCode : '') - void sendAccountActivationEmail({ + sendAccountActivationEmail({ firstName, lastName, email, @@ -385,7 +385,7 @@ export class UserResolver { logger.info(`optInCode for ${email}=${user.emailContact}`) - void sendResetPasswordEmail({ + sendResetPasswordEmail({ firstName: user.firstName, lastName: user.lastName, email, @@ -789,7 +789,7 @@ export class UserResolver { await user.emailContact.save() // eslint-disable-next-line @typescript-eslint/no-unused-vars - const emailSent = await sendAccountActivationEmail({ + sendAccountActivationEmail({ firstName: user.firstName, lastName: user.lastName, email, @@ -798,10 +798,6 @@ export class UserResolver { timeDurationObject: getTimeDurationObject(CONFIG.EMAIL_CODE_VALID_TIME), }) - // In case EMails are disabled log the activation link for the user - if (!emailSent) { - logger.info(`Account confirmation link: ${activationLink}`) - } await EVENT_EMAIL_ADMIN_CONFIRMATION(user, getUser(context)) return true