mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
emails are async again
This commit is contained in:
parent
a7add429f8
commit
3eb95e19b9
@ -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<string, unknown>
|
||||
}): boolean | null => {
|
||||
}): Promise<Record<string, unknown> | 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
|
||||
}
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -13,7 +13,7 @@ export const sendAddedContributionMessageEmail = (data: {
|
||||
senderFirstName: string
|
||||
senderLastName: string
|
||||
contributionMemo: string
|
||||
}): boolean | null => {
|
||||
}): Promise<Record<string, unknown> | 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<string, unknown>
|
||||
}): boolean | null => {
|
||||
}): Promise<Record<string, unknown> | 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<Record<string, unknown> | 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<Record<string, unknown> | 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<Record<string, unknown> | 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<Record<string, unknown> | 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<string, unknown>
|
||||
}): boolean | null => {
|
||||
}): Promise<Record<string, unknown> | 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<Record<string, unknown> | 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<Record<string, unknown> | boolean | null> => {
|
||||
return sendEmailTranslated({
|
||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||
template: 'transactionReceived',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user