mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Refactor 'sendTransactionReceivedEmail' email to HTML and translatable
This commit is contained in:
parent
0cccdb56de
commit
3903e29e16
@ -168,3 +168,29 @@ export const sendTransactionLinkRedeemedEmail = (data: {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sendTransactionReceivedEmail = (data: {
|
||||||
|
firstName: string
|
||||||
|
lastName: string
|
||||||
|
email: string
|
||||||
|
language: string
|
||||||
|
senderFirstName: string
|
||||||
|
senderLastName: string
|
||||||
|
senderEmail: string
|
||||||
|
transactionAmount: Decimal
|
||||||
|
}): Promise<Record<string, unknown> | null> => {
|
||||||
|
return sendEmailTranslated({
|
||||||
|
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||||
|
template: 'transactionReceived',
|
||||||
|
locals: {
|
||||||
|
firstName: data.firstName,
|
||||||
|
lastName: data.lastName,
|
||||||
|
locale: data.language,
|
||||||
|
senderFirstName: data.senderFirstName,
|
||||||
|
senderLastName: data.senderLastName,
|
||||||
|
senderEmail: data.senderEmail,
|
||||||
|
transactionAmount: decimalSeparatorByLanguage(data.transactionAmount, data.language),
|
||||||
|
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ html(lang=locale)
|
|||||||
p= t('emails.general.amountGDD', { amountGDD: transactionAmount })
|
p= t('emails.general.amountGDD', { amountGDD: transactionAmount })
|
||||||
br
|
br
|
||||||
span= t('emails.transactionLinkRedeemed.memo', { transactionMemo })
|
span= t('emails.transactionLinkRedeemed.memo', { transactionMemo })
|
||||||
p= t('emails.transactionLinkRedeemed.detailsYouFindOnLinkToYourAccount')
|
p= t('emails.general.detailsYouFindOnLinkToYourAccount')
|
||||||
span= " "
|
span= " "
|
||||||
a(href=overviewURL) #{overviewURL}
|
a(href=overviewURL) #{overviewURL}
|
||||||
p= t('emails.general.pleaseDoNotReply')
|
p= t('emails.general.pleaseDoNotReply')
|
||||||
|
|||||||
16
backend/src/emails/transactionReceived/html.pug
Normal file
16
backend/src/emails/transactionReceived/html.pug
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
doctype html
|
||||||
|
html(lang=locale)
|
||||||
|
head
|
||||||
|
title= t('emails.transactionReceived.subject')
|
||||||
|
body
|
||||||
|
h1(style='margin-bottom: 24px;')= t('emails.transactionReceived.subject')
|
||||||
|
#container.col
|
||||||
|
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
||||||
|
p= t('emails.transactionReceived.haveReceivedAmountGDDFrom', { transactionAmount, senderFirstName, senderLastName, senderEmail })
|
||||||
|
p= t('emails.general.detailsYouFindOnLinkToYourAccount')
|
||||||
|
span= " "
|
||||||
|
a(href=overviewURL) #{overviewURL}
|
||||||
|
p= t('emails.general.pleaseDoNotReply')
|
||||||
|
p(style='margin-top: 24px;')= t('emails.general.sincerelyYours')
|
||||||
|
br
|
||||||
|
span= t('emails.general.yourGradidoTeam')
|
||||||
1
backend/src/emails/transactionReceived/subject.pug
Normal file
1
backend/src/emails/transactionReceived/subject.pug
Normal file
@ -0,0 +1 @@
|
|||||||
|
= t('emails.transactionReceived.subject')
|
||||||
@ -2,14 +2,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
|
||||||
import { backendLogger as logger } from '@/server/logger'
|
import { backendLogger as logger } from '@/server/logger'
|
||||||
import CONFIG from '@/config'
|
|
||||||
|
|
||||||
import { Context, getUser } from '@/server/context'
|
import { Context, getUser } from '@/server/context'
|
||||||
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql'
|
||||||
import { getCustomRepository, getConnection, In } from '@dbTools/typeorm'
|
import { getCustomRepository, getConnection, In } from '@dbTools/typeorm'
|
||||||
|
|
||||||
import { sendTransactionReceivedEmail } from '@/mailer/sendTransactionReceivedEmail'
|
|
||||||
|
|
||||||
import { Transaction } from '@model/Transaction'
|
import { Transaction } from '@model/Transaction'
|
||||||
import { TransactionList } from '@model/TransactionList'
|
import { TransactionList } from '@model/TransactionList'
|
||||||
|
|
||||||
@ -36,7 +33,10 @@ import Decimal from 'decimal.js-light'
|
|||||||
import { BalanceResolver } from './BalanceResolver'
|
import { BalanceResolver } from './BalanceResolver'
|
||||||
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
|
||||||
import { findUserByEmail } from './UserResolver'
|
import { findUserByEmail } from './UserResolver'
|
||||||
import { sendTransactionLinkRedeemedEmail } from '@/emails/sendEmailVariants'
|
import {
|
||||||
|
sendTransactionLinkRedeemedEmail,
|
||||||
|
sendTransactionReceivedEmail,
|
||||||
|
} from '@/emails/sendEmailVariants'
|
||||||
import { Event, EventTransactionReceive, EventTransactionSend } from '@/event/Event'
|
import { Event, EventTransactionReceive, EventTransactionSend } from '@/event/Event'
|
||||||
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
||||||
import { Decay } from '../model/Decay'
|
import { Decay } from '../model/Decay'
|
||||||
@ -168,17 +168,15 @@ export const executeTransaction = async (
|
|||||||
await queryRunner.release()
|
await queryRunner.release()
|
||||||
}
|
}
|
||||||
logger.debug(`prepare Email for transaction received...`)
|
logger.debug(`prepare Email for transaction received...`)
|
||||||
// send notification email
|
|
||||||
// TODO: translate
|
|
||||||
await sendTransactionReceivedEmail({
|
await sendTransactionReceivedEmail({
|
||||||
|
firstName: recipient.firstName,
|
||||||
|
lastName: recipient.lastName,
|
||||||
|
email: recipient.emailContact.email,
|
||||||
|
language: recipient.language,
|
||||||
senderFirstName: sender.firstName,
|
senderFirstName: sender.firstName,
|
||||||
senderLastName: sender.lastName,
|
senderLastName: sender.lastName,
|
||||||
recipientFirstName: recipient.firstName,
|
|
||||||
recipientLastName: recipient.lastName,
|
|
||||||
email: recipient.emailContact.email,
|
|
||||||
senderEmail: sender.emailContact.email,
|
senderEmail: sender.emailContact.email,
|
||||||
amount,
|
transactionAmount: amount,
|
||||||
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
|
||||||
})
|
})
|
||||||
if (transactionLink) {
|
if (transactionLink) {
|
||||||
await sendTransactionLinkRedeemedEmail({
|
await sendTransactionLinkRedeemedEmail({
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
"amountGDD": "Betrag: {amountGDD} GDD",
|
"amountGDD": "Betrag: {amountGDD} GDD",
|
||||||
|
"detailsYouFindOnLinkToYourAccount": "Details zur Transaktion findest du in deinem Gradido-Konto:",
|
||||||
"helloName": "Hallo {firstName} {lastName},",
|
"helloName": "Hallo {firstName} {lastName},",
|
||||||
"linkToYourAccount": "Link zu deinem Konto:",
|
"linkToYourAccount": "Link zu deinem Konto:",
|
||||||
"orCopyLink": "oder kopiere den obigen Link in dein Browserfenster.",
|
"orCopyLink": "oder kopiere den obigen Link in dein Browserfenster.",
|
||||||
@ -44,10 +45,13 @@
|
|||||||
"youOrSomeoneResetPassword": "du, oder jemand anderes, hast für dieses Konto ein Zurücksetzen des Passworts angefordert."
|
"youOrSomeoneResetPassword": "du, oder jemand anderes, hast für dieses Konto ein Zurücksetzen des Passworts angefordert."
|
||||||
},
|
},
|
||||||
"transactionLinkRedeemed": {
|
"transactionLinkRedeemed": {
|
||||||
"detailsYouFindOnLinkToYourAccount": "Details zur Transaktion findest du in deinem Gradido-Konto:",
|
|
||||||
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) hat soeben deinen Link eingelöst.",
|
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) hat soeben deinen Link eingelöst.",
|
||||||
"memo": "Memo: {transactionMemo}",
|
"memo": "Memo: {transactionMemo}",
|
||||||
"subject": "Gradido: Dein Gradido-Link wurde eingelöst"
|
"subject": "Gradido: Dein Gradido-Link wurde eingelöst"
|
||||||
|
},
|
||||||
|
"transactionReceived": {
|
||||||
|
"haveReceivedAmountGDDFrom": "du hast soeben {transactionAmount} GDD von {senderFirstName} {senderLastName} ({senderEmail}) erhalten.",
|
||||||
|
"subject": "Gradido: Du hast Gradidos erhalten"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
"amountGDD": "Amount: {amountGDD} GDD",
|
"amountGDD": "Amount: {amountGDD} GDD",
|
||||||
|
"detailsYouFindOnLinkToYourAccount": "You can find transaction details in your Gradido account:",
|
||||||
"helloName": "Hello {firstName} {lastName}",
|
"helloName": "Hello {firstName} {lastName}",
|
||||||
"linkToYourAccount": "Link to your account:",
|
"linkToYourAccount": "Link to your account:",
|
||||||
"orCopyLink": "or copy the link above into your browser window.",
|
"orCopyLink": "or copy the link above into your browser window.",
|
||||||
@ -44,10 +45,13 @@
|
|||||||
"youOrSomeoneResetPassword": "You, or someone else, requested a password reset for this account."
|
"youOrSomeoneResetPassword": "You, or someone else, requested a password reset for this account."
|
||||||
},
|
},
|
||||||
"transactionLinkRedeemed": {
|
"transactionLinkRedeemed": {
|
||||||
"detailsYouFindOnLinkToYourAccount": "You can find transaction details in your Gradido account:",
|
|
||||||
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) has just redeemed your link.",
|
"hasRedeemedYourLink": "{senderFirstName} {senderLastName} ({senderEmail}) has just redeemed your link.",
|
||||||
"memo": "Memo: {transactionMemo}",
|
"memo": "Memo: {transactionMemo}",
|
||||||
"subject": "Gradido: Your Gradido link has been redeemed"
|
"subject": "Gradido: Your Gradido link has been redeemed"
|
||||||
|
},
|
||||||
|
"transactionReceived": {
|
||||||
|
"haveReceivedAmountGDDFrom": "You have just received {transactionAmount} GDD from {senderFirstName} {senderLastName} ({senderEmail}).",
|
||||||
|
"subject": "Gradido: You have received Gradidos"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"general": {
|
"general": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user