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 CONFIG from '@/config'
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
|
|
||||||
export const sendEmailTranslated = ({
|
export const sendEmailTranslated = async ({
|
||||||
receiver,
|
receiver,
|
||||||
template,
|
template,
|
||||||
locals,
|
locals,
|
||||||
@ -18,7 +18,7 @@ export const sendEmailTranslated = ({
|
|||||||
}
|
}
|
||||||
template: string
|
template: string
|
||||||
locals: Record<string, unknown>
|
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'
|
// 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) {
|
if (!CONFIG.EMAIL) {
|
||||||
@ -65,7 +65,7 @@ export const sendEmailTranslated = ({
|
|||||||
// i18n, // is only needed if you don't install i18n
|
// i18n, // is only needed if you don't install i18n
|
||||||
})
|
})
|
||||||
|
|
||||||
void email
|
const resultSend = await email
|
||||||
.send({
|
.send({
|
||||||
template: path.join(__dirname, 'templates', template),
|
template: path.join(__dirname, 'templates', template),
|
||||||
message: receiver,
|
message: receiver,
|
||||||
@ -76,5 +76,5 @@ export const sendEmailTranslated = ({
|
|||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
return true
|
return resultSend
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -159,7 +159,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -235,7 +235,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -323,7 +323,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -401,7 +401,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -479,7 +479,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -555,7 +555,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -639,7 +639,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
@ -718,7 +718,7 @@ describe('sendEmailVariants', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it.skip('has expected result', () => {
|
it('has expected result', () => {
|
||||||
expect(result).toMatchObject({
|
expect(result).toMatchObject({
|
||||||
envelope: {
|
envelope: {
|
||||||
from: 'info@gradido.net',
|
from: 'info@gradido.net',
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export const sendAddedContributionMessageEmail = (data: {
|
|||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
contributionMemo: string
|
contributionMemo: string
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: {
|
receiver: {
|
||||||
to: `${data.firstName} ${data.lastName} <${data.email}>`,
|
to: `${data.firstName} ${data.lastName} <${data.email}>`,
|
||||||
@ -40,7 +40,7 @@ export const sendAccountActivationEmail = (data: {
|
|||||||
language: string
|
language: string
|
||||||
activationLink: string
|
activationLink: string
|
||||||
timeDurationObject: Record<string, unknown>
|
timeDurationObject: Record<string, unknown>
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'accountActivation',
|
template: 'accountActivation',
|
||||||
@ -62,7 +62,7 @@ export const sendAccountMultiRegistrationEmail = (data: {
|
|||||||
lastName: string
|
lastName: string
|
||||||
email: string
|
email: string
|
||||||
language: string
|
language: string
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'accountMultiRegistration',
|
template: 'accountMultiRegistration',
|
||||||
@ -86,7 +86,7 @@ export const sendContributionConfirmedEmail = (data: {
|
|||||||
senderLastName: string
|
senderLastName: string
|
||||||
contributionMemo: string
|
contributionMemo: string
|
||||||
contributionAmount: Decimal
|
contributionAmount: Decimal
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'contributionConfirmed',
|
template: 'contributionConfirmed',
|
||||||
@ -113,7 +113,7 @@ export const sendContributionDeletedEmail = (data: {
|
|||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
contributionMemo: string
|
contributionMemo: string
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'contributionDeleted',
|
template: 'contributionDeleted',
|
||||||
@ -139,7 +139,7 @@ export const sendContributionDeniedEmail = (data: {
|
|||||||
senderFirstName: string
|
senderFirstName: string
|
||||||
senderLastName: string
|
senderLastName: string
|
||||||
contributionMemo: string
|
contributionMemo: string
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'contributionDenied',
|
template: 'contributionDenied',
|
||||||
@ -164,7 +164,7 @@ export const sendResetPasswordEmail = (data: {
|
|||||||
language: string
|
language: string
|
||||||
resetLink: string
|
resetLink: string
|
||||||
timeDurationObject: Record<string, unknown>
|
timeDurationObject: Record<string, unknown>
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'resetPassword',
|
template: 'resetPassword',
|
||||||
@ -191,7 +191,7 @@ export const sendTransactionLinkRedeemedEmail = (data: {
|
|||||||
senderEmail: string
|
senderEmail: string
|
||||||
transactionMemo: string
|
transactionMemo: string
|
||||||
transactionAmount: Decimal
|
transactionAmount: Decimal
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'transactionLinkRedeemed',
|
template: 'transactionLinkRedeemed',
|
||||||
@ -220,7 +220,7 @@ export const sendTransactionReceivedEmail = (data: {
|
|||||||
senderLastName: string
|
senderLastName: string
|
||||||
senderEmail: string
|
senderEmail: string
|
||||||
transactionAmount: Decimal
|
transactionAmount: Decimal
|
||||||
}): boolean | null => {
|
}): Promise<Record<string, unknown> | boolean | null> => {
|
||||||
return sendEmailTranslated({
|
return sendEmailTranslated({
|
||||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
template: 'transactionReceived',
|
template: 'transactionReceived',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user