mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Refactor 'sendContributionConfirmedEmail' email to HTML and translatable
This commit is contained in:
parent
a82f0a2864
commit
c87ffd5b8a
@ -8,10 +8,10 @@ html(lang=locale)
|
||||
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
||||
p= t('emails.addedContributionMessage.commonGoodContributionMessage', { senderFirstName, senderLastName, contributionMemo })
|
||||
p= t('emails.addedContributionMessage.toSeeAndAnswerMessage')
|
||||
p= t('emails.addedContributionMessage.linkToYourAccount')
|
||||
p= t('emails.general.linkToYourAccount')
|
||||
span= " "
|
||||
a(href=overviewURL) #{overviewURL}
|
||||
p= t('emails.addedContributionMessage.pleaseDoNotReply')
|
||||
p= t('emails.general.pleaseDoNotReply')
|
||||
p(style='margin-top: 24px;')= t('emails.general.sincerelyYours')
|
||||
br
|
||||
span= t('emails.general.yourGradidoTeam')
|
||||
|
||||
17
backend/src/emails/contributionConfirmed/html.pug
Normal file
17
backend/src/emails/contributionConfirmed/html.pug
Normal file
@ -0,0 +1,17 @@
|
||||
doctype html
|
||||
html(lang=locale)
|
||||
head
|
||||
title= t('emails.contributionConfirmed.subject')
|
||||
body
|
||||
h1(style='margin-bottom: 24px;')= t('emails.contributionConfirmed.subject')
|
||||
#container.col
|
||||
p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName })
|
||||
p= t('emails.contributionConfirmed.commonGoodContributionConfirmed', { senderFirstName, senderLastName, contributionMemo })
|
||||
p= t('emails.contributionConfirmed.contributionAmount', { contributionAmount })
|
||||
p= t('emails.general.linkToYourAccount')
|
||||
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/contributionConfirmed/subject.pug
Normal file
1
backend/src/emails/contributionConfirmed/subject.pug
Normal file
@ -0,0 +1 @@
|
||||
= t('emails.contributionConfirmed.subject')
|
||||
@ -1,11 +1,10 @@
|
||||
import CONFIG from '@/config'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import path from 'path'
|
||||
import { createTransport } from 'nodemailer'
|
||||
import Email from 'email-templates'
|
||||
import i18n from 'i18n'
|
||||
|
||||
import CONFIG from '@/config'
|
||||
|
||||
export const sendEmailTranslated = async (params: {
|
||||
receiver: {
|
||||
to: string
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import i18n from 'i18n'
|
||||
import Decimal from 'decimal.js-light'
|
||||
import CONFIG from '@/config'
|
||||
import { sendEmailTranslated } from './sendEmailTranslated'
|
||||
|
||||
@ -66,3 +68,35 @@ export const sendAccountMultiRegistrationEmail = (data: {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const sendContributionConfirmedEmail = (data: {
|
||||
firstName: string
|
||||
lastName: string
|
||||
email: string
|
||||
language: string
|
||||
senderFirstName: string
|
||||
senderLastName: string
|
||||
contributionMemo: string
|
||||
contributionAmount: Decimal
|
||||
}): Promise<Record<string, unknown> | null> => {
|
||||
const rememberLocaleToRestore = i18n.getLocale()
|
||||
i18n.setLocale(data.language)
|
||||
const contributionAmount = data.contributionAmount
|
||||
.toFixed(2)
|
||||
.replace('.', i18n.__('emails.general.decimalSeparator'))
|
||||
i18n.setLocale(rememberLocaleToRestore)
|
||||
return sendEmailTranslated({
|
||||
receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` },
|
||||
template: 'contributionConfirmed',
|
||||
locals: {
|
||||
firstName: data.firstName,
|
||||
lastName: data.lastName,
|
||||
locale: data.language,
|
||||
senderFirstName: data.senderFirstName,
|
||||
senderLastName: data.senderLastName,
|
||||
contributionMemo: data.contributionMemo,
|
||||
contributionAmount,
|
||||
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -43,6 +43,7 @@ import { findUserByEmail, activationLink, getTimeDurationObject } from './UserRe
|
||||
import {
|
||||
sendAddedContributionMessageEmail,
|
||||
sendAccountActivationEmail,
|
||||
sendContributionConfirmedEmail,
|
||||
} from '@/emails/sendEmailVariants'
|
||||
import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver'
|
||||
import CONFIG from '@/config'
|
||||
@ -66,7 +67,6 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi
|
||||
import ContributionMessageArgs from '@arg/ContributionMessageArgs'
|
||||
import { ContributionMessageType } from '@enum/MessageType'
|
||||
import { ContributionMessage } from '@model/ContributionMessage'
|
||||
import { sendContributionConfirmedEmail } from '@/mailer/sendContributionConfirmedEmail'
|
||||
import { sendContributionRejectedEmail } from '@/mailer/sendContributionRejectedEmail'
|
||||
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
||||
import {
|
||||
@ -584,14 +584,14 @@ export class AdminResolver {
|
||||
await queryRunner.commitTransaction()
|
||||
logger.info('creation commited successfuly.')
|
||||
sendContributionConfirmedEmail({
|
||||
firstName: user.firstName,
|
||||
lastName: user.lastName,
|
||||
email: user.emailContact.email,
|
||||
language: user.language,
|
||||
senderFirstName: moderatorUser.firstName,
|
||||
senderLastName: moderatorUser.lastName,
|
||||
recipientFirstName: user.firstName,
|
||||
recipientLastName: user.lastName,
|
||||
recipientEmail: user.emailContact.email,
|
||||
contributionMemo: contribution.memo,
|
||||
contributionAmount: contribution.amount,
|
||||
overviewURL: CONFIG.EMAIL_LINK_OVERVIEW,
|
||||
})
|
||||
} catch (e) {
|
||||
await queryRunner.rollbackTransaction()
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
"emails": {
|
||||
"addedContributionMessage": {
|
||||
"commonGoodContributionMessage": "du hast zu deinem Gemeinwohl-Beitrag „{contributionMemo}“ eine Nachricht von {senderFirstName} {senderLastName} erhalten.",
|
||||
"linkToYourAccount": "Link zu deinem Konto:",
|
||||
"pleaseDoNotReply": "Bitte antworte nicht auf diese E-Mail!",
|
||||
"subject": "Gradido: Nachricht zu deinem Gemeinwohl-Beitrag",
|
||||
"toSeeAndAnswerMessage": "Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!"
|
||||
},
|
||||
@ -22,8 +20,16 @@
|
||||
"onForgottenPasswordCopyLink": "oder kopiere den obigen Link in dein Browserfenster.",
|
||||
"subject": "Gradido: Erneuter Registrierungsversuch mit deiner E-Mail"
|
||||
},
|
||||
"contributionConfirmed": {
|
||||
"commonGoodContributionConfirmed": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde soeben von {senderFirstName} {senderLastName} bestätigt und in deinem Gradido-Konto gutgeschrieben.",
|
||||
"contributionAmount": "Betrag: {contributionAmount} GDD",
|
||||
"subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt"
|
||||
},
|
||||
"general": {
|
||||
"decimalSeparator": ",",
|
||||
"helloName": "Hallo {firstName} {lastName},",
|
||||
"linkToYourAccount": "Link zu deinem Konto:",
|
||||
"pleaseDoNotReply": "Bitte antworte nicht auf diese E-Mail!",
|
||||
"sincerelyYours": "Liebe Grüße",
|
||||
"yourGradidoTeam": "dein Gradido-Team"
|
||||
}
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
"emails": {
|
||||
"addedContributionMessage": {
|
||||
"commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.",
|
||||
"linkToYourAccount": "Link to your account:",
|
||||
"pleaseDoNotReply": "Please do not reply to this email!",
|
||||
"subject": "Gradido: Message about your common good contribution",
|
||||
"toSeeAndAnswerMessage": "To view and reply to the message, go to the “Community” menu in your Gradido account and click on the “My Contributions to the Common Good” tab!"
|
||||
},
|
||||
@ -22,8 +20,16 @@
|
||||
"onForgottenPasswordCopyLink": "or copy the link above into your browser window.",
|
||||
"subject": "Gradido: Try To Register Again With Your Email"
|
||||
},
|
||||
"contributionConfirmed": {
|
||||
"commonGoodContributionConfirmed": "your public good contribution “{contributionMemo}” has just been confirmed by {senderFirstName} {senderLastName} and credited to your Gradido account.",
|
||||
"contributionAmount": "Amount: {contributionAmount} GDD",
|
||||
"subject": "Gradido: Your common good contribution was confirmed"
|
||||
},
|
||||
"general": {
|
||||
"decimalSeparator": ".",
|
||||
"helloName": "Hello {firstName} {lastName}",
|
||||
"linkToYourAccount": "Link to your account:",
|
||||
"pleaseDoNotReply": "Please do not reply to this email!",
|
||||
"sincerelyYours": "Kind regards,",
|
||||
"yourGradidoTeam": "your Gradido team"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user