From 417c7b2943564a70c722f1e75dd170bd131fa591 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:24:06 +0200 Subject: [PATCH 01/11] fix config, email_smtp_port is number --- backend/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 23ede1f27..a084f7b32 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -76,7 +76,7 @@ const email = { EMAIL_SENDER: process.env.EMAIL_SENDER || 'info@gradido.net', EMAIL_PASSWORD: process.env.EMAIL_PASSWORD || '', EMAIL_SMTP_URL: process.env.EMAIL_SMTP_URL || 'mailserver', - EMAIL_SMTP_PORT: process.env.EMAIL_SMTP_PORT || '1025', + EMAIL_SMTP_PORT: Number(process.env.EMAIL_SMTP_PORT) || 1025, // eslint-disable-next-line no-unneeded-ternary EMAIL_TLS: process.env.EMAIL_TLS === 'false' ? false : true, EMAIL_LINK_VERIFICATION: From dd86e51121916ab76b9e97bff5ee5ccbe2c22981 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:24:25 +0200 Subject: [PATCH 02/11] email_smtp_port is number --- backend/src/emails/sendEmailTranslated.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 85074344a..0dcee1469 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -10,7 +10,7 @@ import { sendEmailTranslated } from './sendEmailTranslated' CONFIG.EMAIL = false CONFIG.EMAIL_SMTP_URL = 'EMAIL_SMTP_URL' -CONFIG.EMAIL_SMTP_PORT = '1234' +CONFIG.EMAIL_SMTP_PORT = 1234 CONFIG.EMAIL_USERNAME = 'user' CONFIG.EMAIL_PASSWORD = 'pwd' CONFIG.EMAIL_TLS = true From c6369d1e0b46c2fe8c34faf76c1f4682fd41a633 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:24:51 +0200 Subject: [PATCH 03/11] dont wait for emails --- backend/src/emails/sendEmailTranslated.ts | 32 +++++++------------ .../resolver/ContributionMessageResolver.ts | 2 +- .../graphql/resolver/TransactionResolver.ts | 4 +-- backend/src/graphql/resolver/UserResolver.ts | 23 +++---------- 4 files changed, 19 insertions(+), 42 deletions(-) diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index 6d89cc257..f04fd377f 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -16,13 +16,16 @@ export const sendEmailTranslated = async (params: { } template: string locals: Record -}): Promise | null> => { - let resultSend: Record | null = null - +}): Promise => { // TODO: test the calling order of 'i18n.setLocale' for example: language of logging 'en', language of email receiver 'es', reset language of current user 'de' + if (!CONFIG.EMAIL) { + logger.info(`Emails are disabled via config...`) + return null + } + // because language of receiver can differ from language of current user who triggers the sending - const rememberLocaleToRestore = i18n.getLocale() + // const rememberLocaleToRestore = i18n.getLocale() i18n.setLocale('en') // for logging logger.info( @@ -31,10 +34,6 @@ export const sendEmailTranslated = async (params: { `, subject=${i18n.__('emails.' + params.template + '.subject')}`, ) - if (!CONFIG.EMAIL) { - logger.info(`Emails are disabled via config...`) - return null - } if (CONFIG.EMAIL_TEST_MODUS) { logger.info( `Testmodus=ON: change receiver from ${params.receiver.to} to ${CONFIG.EMAIL_TEST_RECEIVER}`, @@ -43,7 +42,7 @@ export const sendEmailTranslated = async (params: { } const transport = createTransport({ host: CONFIG.EMAIL_SMTP_URL, - port: Number(CONFIG.EMAIL_SMTP_PORT), + port: CONFIG.EMAIL_SMTP_PORT, secure: false, // true for 465, false for other ports requireTLS: CONFIG.EMAIL_TLS, auth: { @@ -64,23 +63,16 @@ export const sendEmailTranslated = async (params: { // i18n, // is only needed if you don't install i18n }) - // ATTENTION: await is needed, because otherwise on send the email gets send in the language of the current user, because below the language gets reset - await email + void email .send({ template: path.join(__dirname, 'templates', params.template), message: params.receiver, locals: params.locals, // the 'locale' in here seems not to be used by 'email-template', because it doesn't work if the language isn't set before by 'i18n.setLocale' }) - .then((result: Record) => { - resultSend = result - logger.info('Send email successfully !!!') - logger.info('Result: ', result) - }) .catch((error: unknown) => { - throw new LogError('Error sending notification email', error) + new LogError('Error sending notification email', error) + return false; }) - i18n.setLocale(rememberLocaleToRestore) - - return resultSend + return true; } diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index e0b4e7b96..a59023036 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) } - await sendAddedContributionMessageEmail({ + void sendAddedContributionMessageEmail({ firstName: contribution.user.firstName, lastName: contribution.user.lastName, email: contribution.user.emailContact.email, diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 4c8ab0061..0d7d7abf5 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() } - await sendTransactionReceivedEmail({ + void sendTransactionReceivedEmail({ firstName: recipient.firstName, lastName: recipient.lastName, email: recipient.emailContact.email, @@ -160,7 +160,7 @@ export const executeTransaction = async ( transactionAmount: amount, }) if (transactionLink) { - await sendTransactionLinkRedeemedEmail({ + void 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 d6b1f22bc..d4aa6c8b3 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) - const emailSent = await sendAccountMultiRegistrationEmail({ + void 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, @@ -258,9 +258,6 @@ export class UserResolver { ) /* uncomment this, when you need the activation link on the console */ // In case EMails are disabled log the activation link for the user - if (!emailSent) { - logger.debug(`Email not send!`) - } logger.info('createUser() faked and send multi registration mail...') return user @@ -325,8 +322,7 @@ export class UserResolver { emailContact.emailVerificationCode.toString(), ).replace(/{code}/g, redeemCode ? '/' + redeemCode : '') - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const emailSent = await sendAccountActivationEmail({ + void sendAccountActivationEmail({ firstName, lastName, email, @@ -338,10 +334,6 @@ export class UserResolver { await EVENT_EMAIL_CONFIRMATION(dbUser) - if (!emailSent) { - logger.debug(`Account confirmation link: ${activationLink}`) - } - await queryRunner.commitTransaction() logger.addContext('user', dbUser.id) } catch (e) { @@ -392,8 +384,8 @@ export class UserResolver { }) logger.info(`optInCode for ${email}=${user.emailContact}`) - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const emailSent = await sendResetPasswordEmail({ + + void sendResetPasswordEmail({ firstName: user.firstName, lastName: user.lastName, email, @@ -402,13 +394,6 @@ export class UserResolver { timeDurationObject: getTimeDurationObject(CONFIG.EMAIL_CODE_VALID_TIME), }) - /* uncomment this, when you need the activation link on the console */ - // In case EMails are disabled log the activation link for the user - if (!emailSent) { - logger.debug( - `Reset password link: ${activationLink(user.emailContact.emailVerificationCode)}`, - ) - } logger.info(`forgotPassword(${email}) successful...`) await EVENT_EMAIL_FORGOT_PASSWORD(user) From 136f282e6c867bcf3b1710c92ab216b72015de50 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:44:41 +0200 Subject: [PATCH 04/11] properly destructure params in sendEMailTranslated --- .../src/emails/sendEmailTranslated.test.ts | 14 ++++---- backend/src/emails/sendEmailTranslated.ts | 34 ++++++++++--------- backend/src/graphql/resolver/UserResolver.ts | 2 +- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index 0dcee1469..ceb66ddc9 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -31,11 +31,11 @@ jest.mock('nodemailer', () => { }) describe('sendEmailTranslated', () => { - let result: Record | null + let result: boolean | null describe('config email is false', () => { - beforeEach(async () => { - result = await sendEmailTranslated({ + beforeEach(() => { + result = sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -57,9 +57,9 @@ describe('sendEmailTranslated', () => { }) describe('config email is true', () => { - beforeEach(async () => { + beforeEach(() => { CONFIG.EMAIL = true - result = await sendEmailTranslated({ + result = sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -117,11 +117,11 @@ describe('sendEmailTranslated', () => { }) describe('with email EMAIL_TEST_MODUS true', () => { - beforeEach(async () => { + beforeEach(() => { jest.clearAllMocks() CONFIG.EMAIL = true CONFIG.EMAIL_TEST_MODUS = true - result = await sendEmailTranslated({ + result = sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index f04fd377f..61554c025 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/restrict-template-expressions */ import path from 'path' import Email from 'email-templates' @@ -6,17 +5,20 @@ import i18n from 'i18n' import { createTransport } from 'nodemailer' import CONFIG from '@/config' -import LogError from '@/server/LogError' import { backendLogger as logger } from '@/server/logger' -export const sendEmailTranslated = async (params: { +export const sendEmailTranslated = ({ + receiver, + template, + locals, +}: { receiver: { to: string cc?: string } template: string locals: Record -}): Promise => { +}): boolean | null => { // TODO: test the calling order of 'i18n.setLocale' for example: language of logging 'en', language of email receiver 'es', reset language of current user 'de' if (!CONFIG.EMAIL) { @@ -29,16 +31,16 @@ export const sendEmailTranslated = async (params: { i18n.setLocale('en') // for logging logger.info( - `send Email: language=${params.locals.locale} to=${params.receiver.to}` + - (params.receiver.cc ? `, cc=${params.receiver.cc}` : '') + - `, subject=${i18n.__('emails.' + params.template + '.subject')}`, + `send Email: language=${locals.locale as string} to=${receiver.to}` + + (receiver.cc ? `, cc=${receiver.cc}` : '') + + `, subject=${i18n.__('emails.' + template + '.subject')}`, ) if (CONFIG.EMAIL_TEST_MODUS) { logger.info( - `Testmodus=ON: change receiver from ${params.receiver.to} to ${CONFIG.EMAIL_TEST_RECEIVER}`, + `Testmodus=ON: change receiver from ${receiver.to} to ${CONFIG.EMAIL_TEST_RECEIVER}`, ) - params.receiver.to = CONFIG.EMAIL_TEST_RECEIVER + receiver.to = CONFIG.EMAIL_TEST_RECEIVER } const transport = createTransport({ host: CONFIG.EMAIL_SMTP_URL, @@ -51,7 +53,7 @@ export const sendEmailTranslated = async (params: { }, }) - i18n.setLocale(params.locals.locale as string) // for email + i18n.setLocale(locals.locale as string) // for email // TESTING: see 'README.md' const email = new Email({ @@ -65,14 +67,14 @@ export const sendEmailTranslated = async (params: { void email .send({ - template: path.join(__dirname, 'templates', params.template), - message: params.receiver, - locals: params.locals, // the 'locale' in here seems not to be used by 'email-template', because it doesn't work if the language isn't set before by 'i18n.setLocale' + template: path.join(__dirname, 'templates', template), + message: receiver, + locals, // the 'locale' in here seems not to be used by 'email-template', because it doesn't work if the language isn't set before by 'i18n.setLocale' }) .catch((error: unknown) => { - new LogError('Error sending notification email', error) - return false; + logger.error('Error sending notification email', error) + return false }) - return true; + return true } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index d4aa6c8b3..ba230e6c7 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -384,7 +384,7 @@ export class UserResolver { }) logger.info(`optInCode for ${email}=${user.emailContact}`) - + void sendResetPasswordEmail({ firstName: user.firstName, lastName: user.lastName, From 2488fe7b68a03ae917b36feaea90969cf03d91e4 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:47:55 +0200 Subject: [PATCH 05/11] corrected email varriant response type --- backend/src/emails/sendEmailVariants.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index b45e7fc67..faf1ba2e0 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -13,7 +13,7 @@ export const sendAddedContributionMessageEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>`, @@ -40,7 +40,7 @@ export const sendAccountActivationEmail = (data: { language: string activationLink: string timeDurationObject: Record -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'accountActivation', @@ -62,7 +62,7 @@ export const sendAccountMultiRegistrationEmail = (data: { lastName: string email: string language: string -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'accountMultiRegistration', @@ -86,7 +86,7 @@ export const sendContributionConfirmedEmail = (data: { senderLastName: string contributionMemo: string contributionAmount: Decimal -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionConfirmed', @@ -113,7 +113,7 @@ export const sendContributionDeletedEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionDeleted', @@ -139,7 +139,7 @@ export const sendContributionDeniedEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionDenied', @@ -164,7 +164,7 @@ export const sendResetPasswordEmail = (data: { language: string resetLink: string timeDurationObject: Record -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'resetPassword', @@ -191,7 +191,7 @@ export const sendTransactionLinkRedeemedEmail = (data: { senderEmail: string transactionMemo: string transactionAmount: Decimal -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'transactionLinkRedeemed', @@ -220,7 +220,7 @@ export const sendTransactionReceivedEmail = (data: { senderLastName: string senderEmail: string transactionAmount: Decimal -}): Promise | null> => { +}): boolean | null => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'transactionReceived', From bbe1167b97fd269073a712419bfba5cf2be3c32d Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 02:53:25 +0200 Subject: [PATCH 06/11] 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 From 493c5befeb228033f9fce3557736254215930a24 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 03:14:16 +0200 Subject: [PATCH 07/11] skip all broken tests --- backend/src/emails/sendEmailTranslated.test.ts | 4 ++-- backend/src/emails/sendEmailVariants.test.ts | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index ceb66ddc9..fb4ceb734 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -85,7 +85,7 @@ describe('sendEmailTranslated', () => { }) describe('call of "sendEmailTranslated"', () => { - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -133,7 +133,7 @@ describe('sendEmailTranslated', () => { }) }) - it('call of "sendEmailTranslated" with faked "to"', () => { + it.skip('call of "sendEmailTranslated" with faked "to"', () => { expect(result).toMatchObject({ envelope: { from: CONFIG.EMAIL_SENDER, diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index e1f3e7cca..da777b7b8 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -83,7 +83,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -159,7 +159,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -235,7 +235,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -401,7 +401,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -479,7 +479,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -555,7 +555,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -639,7 +639,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -718,7 +718,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', From a7add429f8d126fcaadff92dcdf220e0175a6d81 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 5 Apr 2023 03:41:54 +0200 Subject: [PATCH 08/11] missing skip test --- backend/src/emails/sendEmailVariants.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index da777b7b8..fe8ed8c3a 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -323,7 +323,7 @@ describe('sendEmailVariants', () => { }) }) - it('has expected result', () => { + it.skip('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', From 3eb95e19b9b63bfc2c4ec94327f8f527d3059c40 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 11 Apr 2023 12:53:59 +0200 Subject: [PATCH 09/11] emails are async again --- backend/src/emails/sendEmailTranslated.ts | 8 ++++---- backend/src/emails/sendEmailVariants.test.ts | 18 +++++++++--------- backend/src/emails/sendEmailVariants.ts | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index 61554c025..da8b0c67b 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -7,7 +7,7 @@ import { createTransport } from 'nodemailer' import CONFIG from '@/config' import { backendLogger as logger } from '@/server/logger' -export const sendEmailTranslated = ({ +export const sendEmailTranslated = async ({ receiver, template, locals, @@ -18,7 +18,7 @@ export const sendEmailTranslated = ({ } template: string locals: Record -}): boolean | null => { +}): Promise | boolean | null> => { // TODO: test the calling order of 'i18n.setLocale' for example: language of logging 'en', language of email receiver 'es', reset language of current user 'de' if (!CONFIG.EMAIL) { @@ -65,7 +65,7 @@ export const sendEmailTranslated = ({ // i18n, // is only needed if you don't install i18n }) - void email + const resultSend = await email .send({ template: path.join(__dirname, 'templates', template), message: receiver, @@ -76,5 +76,5 @@ export const sendEmailTranslated = ({ return false }) - return true + return resultSend } diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index fe8ed8c3a..e1f3e7cca 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -83,7 +83,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -159,7 +159,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -235,7 +235,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -323,7 +323,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -401,7 +401,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -479,7 +479,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -555,7 +555,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -639,7 +639,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -718,7 +718,7 @@ describe('sendEmailVariants', () => { }) }) - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index faf1ba2e0..19aa9faf5 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -13,7 +13,7 @@ export const sendAddedContributionMessageEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>`, @@ -40,7 +40,7 @@ export const sendAccountActivationEmail = (data: { language: string activationLink: string timeDurationObject: Record -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'accountActivation', @@ -62,7 +62,7 @@ export const sendAccountMultiRegistrationEmail = (data: { lastName: string email: string language: string -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'accountMultiRegistration', @@ -86,7 +86,7 @@ export const sendContributionConfirmedEmail = (data: { senderLastName: string contributionMemo: string contributionAmount: Decimal -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionConfirmed', @@ -113,7 +113,7 @@ export const sendContributionDeletedEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionDeleted', @@ -139,7 +139,7 @@ export const sendContributionDeniedEmail = (data: { senderFirstName: string senderLastName: string contributionMemo: string -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'contributionDenied', @@ -164,7 +164,7 @@ export const sendResetPasswordEmail = (data: { language: string resetLink: string timeDurationObject: Record -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'resetPassword', @@ -191,7 +191,7 @@ export const sendTransactionLinkRedeemedEmail = (data: { senderEmail: string transactionMemo: string transactionAmount: Decimal -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'transactionLinkRedeemed', @@ -220,7 +220,7 @@ export const sendTransactionReceivedEmail = (data: { senderLastName: string senderEmail: string transactionAmount: Decimal -}): boolean | null => { +}): Promise | boolean | null> => { return sendEmailTranslated({ receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, template: 'transactionReceived', From 9c461da0e7d83d4140ac1be7eb0a66ecbded19ab Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 11 Apr 2023 13:01:58 +0200 Subject: [PATCH 10/11] fix emails --- backend/src/emails/sendEmailTranslated.test.ts | 18 +++++++++--------- backend/src/emails/sendEmailTranslated.ts | 2 ++ .../resolver/ContributionMessageResolver.ts | 2 +- .../graphql/resolver/ContributionResolver.ts | 6 +++--- .../graphql/resolver/TransactionResolver.ts | 4 ++-- backend/src/graphql/resolver/UserResolver.ts | 8 ++++---- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/backend/src/emails/sendEmailTranslated.test.ts b/backend/src/emails/sendEmailTranslated.test.ts index fb4ceb734..74eb0c0f2 100644 --- a/backend/src/emails/sendEmailTranslated.test.ts +++ b/backend/src/emails/sendEmailTranslated.test.ts @@ -31,11 +31,11 @@ jest.mock('nodemailer', () => { }) describe('sendEmailTranslated', () => { - let result: boolean | null + let result: Record | boolean | null describe('config email is false', () => { - beforeEach(() => { - result = sendEmailTranslated({ + beforeEach(async () => { + result = await sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -57,9 +57,9 @@ describe('sendEmailTranslated', () => { }) describe('config email is true', () => { - beforeEach(() => { + beforeEach(async () => { CONFIG.EMAIL = true - result = sendEmailTranslated({ + result = await sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -85,7 +85,7 @@ describe('sendEmailTranslated', () => { }) describe('call of "sendEmailTranslated"', () => { - it.skip('has expected result', () => { + it('has expected result', () => { expect(result).toMatchObject({ envelope: { from: 'info@gradido.net', @@ -117,11 +117,11 @@ describe('sendEmailTranslated', () => { }) describe('with email EMAIL_TEST_MODUS true', () => { - beforeEach(() => { + beforeEach(async () => { jest.clearAllMocks() CONFIG.EMAIL = true CONFIG.EMAIL_TEST_MODUS = true - result = sendEmailTranslated({ + result = await sendEmailTranslated({ receiver: { to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -133,7 +133,7 @@ describe('sendEmailTranslated', () => { }) }) - it.skip('call of "sendEmailTranslated" with faked "to"', () => { + it('call of "sendEmailTranslated" with faked "to"', () => { expect(result).toMatchObject({ envelope: { from: CONFIG.EMAIL_SENDER, diff --git a/backend/src/emails/sendEmailTranslated.ts b/backend/src/emails/sendEmailTranslated.ts index da8b0c67b..eba8d817d 100644 --- a/backend/src/emails/sendEmailTranslated.ts +++ b/backend/src/emails/sendEmailTranslated.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ +/* eslint-disable @typescript-eslint/no-unsafe-return */ import path from 'path' import Email from 'email-templates' diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 02e019ea0..a59023036 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) } - sendAddedContributionMessageEmail({ + void 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 1efe9fafa..5969eaef2 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -424,7 +424,7 @@ export class ContributionResolver { contribution.amount, ) - sendContributionDeletedEmail({ + void 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.') - sendContributionConfirmedEmail({ + void sendContributionConfirmedEmail({ firstName: user.firstName, lastName: user.lastName, email: user.emailContact.email, @@ -599,7 +599,7 @@ export class ContributionResolver { contributionToUpdate.amount, ) - sendContributionDeniedEmail({ + void 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 a95294f76..0d7d7abf5 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() } - sendTransactionReceivedEmail({ + void sendTransactionReceivedEmail({ firstName: recipient.firstName, lastName: recipient.lastName, email: recipient.emailContact.email, @@ -160,7 +160,7 @@ export const executeTransaction = async ( transactionAmount: amount, }) if (transactionLink) { - sendTransactionLinkRedeemedEmail({ + void 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 45059a4a7..b8b519a92 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) - sendAccountMultiRegistrationEmail({ + void 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 : '') - sendAccountActivationEmail({ + void sendAccountActivationEmail({ firstName, lastName, email, @@ -385,7 +385,7 @@ export class UserResolver { logger.info(`optInCode for ${email}=${user.emailContact}`) - sendResetPasswordEmail({ + void 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 - sendAccountActivationEmail({ + void sendAccountActivationEmail({ firstName: user.firstName, lastName: user.lastName, email, From 67a5458a97cb7e610f66601afb10ba55e57a12be Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 11 Apr 2023 13:12:51 +0200 Subject: [PATCH 11/11] fix tests --- backend/src/emails/sendEmailVariants.test.ts | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index e9d4f49a5..fa83996cb 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(() => { - result = sendAddedContributionMessageEmail({ + beforeAll(async () => { + result = await sendAddedContributionMessageEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -128,8 +128,8 @@ describe('sendEmailVariants', () => { }) describe('sendAccountActivationEmail', () => { - beforeAll(() => { - result = sendAccountActivationEmail({ + beforeAll(async () => { + result = await sendAccountActivationEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -208,8 +208,8 @@ describe('sendEmailVariants', () => { }) describe('sendAccountMultiRegistrationEmail', () => { - beforeAll(() => { - result = sendAccountMultiRegistrationEmail({ + beforeAll(async () => { + result = await sendAccountMultiRegistrationEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -288,8 +288,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionConfirmedEmail', () => { - beforeAll(() => { - result = sendContributionConfirmedEmail({ + beforeAll(async () => { + result = await sendContributionConfirmedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -368,8 +368,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionDeniedEmail', () => { - beforeAll(() => { - result = sendContributionDeniedEmail({ + beforeAll(async () => { + result = await sendContributionDeniedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -446,8 +446,8 @@ describe('sendEmailVariants', () => { }) describe('sendContributionDeletedEmail', () => { - beforeAll(() => { - result = sendContributionDeletedEmail({ + beforeAll(async () => { + result = await sendContributionDeletedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -524,8 +524,8 @@ describe('sendEmailVariants', () => { }) describe('sendResetPasswordEmail', () => { - beforeAll(() => { - result = sendResetPasswordEmail({ + beforeAll(async () => { + result = await sendResetPasswordEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -602,8 +602,8 @@ describe('sendEmailVariants', () => { }) describe('sendTransactionLinkRedeemedEmail', () => { - beforeAll(() => { - result = sendTransactionLinkRedeemedEmail({ + beforeAll(async () => { + result = await sendTransactionLinkRedeemedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de', @@ -683,8 +683,8 @@ describe('sendEmailVariants', () => { }) describe('sendTransactionReceivedEmail', () => { - beforeAll(() => { - result = sendTransactionReceivedEmail({ + beforeAll(async () => { + result = await sendTransactionReceivedEmail({ firstName: 'Peter', lastName: 'Lustig', email: 'peter@lustig.de',