From 9c461da0e7d83d4140ac1be7eb0a66ecbded19ab Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 11 Apr 2023 13:01:58 +0200 Subject: [PATCH] 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,