From 72213988ac0b91b3d433305273cbbc590ed88d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 24 Nov 2022 16:10:29 +0100 Subject: [PATCH] Refactor 'sendContributionRejectedEmail' email to HTML and translatable --- .../src/emails/contributionRejected/html.pug | 17 +++++++++++++ .../emails/contributionRejected/subject.pug | 1 + backend/src/emails/sendEmailVariants.ts | 24 +++++++++++++++++++ backend/src/graphql/resolver/AdminResolver.ts | 11 ++++----- backend/src/locales/de.json | 5 ++++ backend/src/locales/en.json | 7 +++++- 6 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 backend/src/emails/contributionRejected/html.pug create mode 100644 backend/src/emails/contributionRejected/subject.pug diff --git a/backend/src/emails/contributionRejected/html.pug b/backend/src/emails/contributionRejected/html.pug new file mode 100644 index 000000000..07c014f92 --- /dev/null +++ b/backend/src/emails/contributionRejected/html.pug @@ -0,0 +1,17 @@ +doctype html +html(lang=locale) + head + title= t('emails.contributionRejected.subject') + body + h1(style='margin-bottom: 24px;')= t('emails.contributionRejected.subject') + #container.col + p(style='margin-bottom: 24px;')= t('emails.general.helloName', { firstName, lastName }) + p= t('emails.contributionRejected.commonGoodContributionRejected', { senderFirstName, senderLastName, contributionMemo }) + p= t('emails.contributionRejected.toSeeContributionsAndMessages') + 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') diff --git a/backend/src/emails/contributionRejected/subject.pug b/backend/src/emails/contributionRejected/subject.pug new file mode 100644 index 000000000..cdaae4157 --- /dev/null +++ b/backend/src/emails/contributionRejected/subject.pug @@ -0,0 +1 @@ += t('emails.contributionRejected.subject') \ No newline at end of file diff --git a/backend/src/emails/sendEmailVariants.ts b/backend/src/emails/sendEmailVariants.ts index 8d1dcf8de..1779cc297 100644 --- a/backend/src/emails/sendEmailVariants.ts +++ b/backend/src/emails/sendEmailVariants.ts @@ -100,3 +100,27 @@ export const sendContributionConfirmedEmail = (data: { }, }) } + +export const sendContributionRejectedEmail = (data: { + firstName: string + lastName: string + email: string + language: string + senderFirstName: string + senderLastName: string + contributionMemo: string +}): Promise | null> => { + return sendEmailTranslated({ + receiver: { to: `${data.firstName} ${data.lastName} <${data.email}>` }, + template: 'contributionRejected', + locals: { + firstName: data.firstName, + lastName: data.lastName, + locale: data.language, + senderFirstName: data.senderFirstName, + senderLastName: data.senderLastName, + contributionMemo: data.contributionMemo, + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, + }, + }) +} diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 8c4f2e00b..993fe8c3b 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -44,6 +44,7 @@ import { sendAddedContributionMessageEmail, sendAccountActivationEmail, sendContributionConfirmedEmail, + sendContributionRejectedEmail, } from '@/emails/sendEmailVariants' import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import CONFIG from '@/config' @@ -67,7 +68,6 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi import ContributionMessageArgs from '@arg/ContributionMessageArgs' import { ContributionMessageType } from '@enum/MessageType' import { ContributionMessage } from '@model/ContributionMessage' -import { sendContributionRejectedEmail } from '@/mailer/sendContributionRejectedEmail' import { eventProtocol } from '@/event/EventProtocolEmitter' import { Event, @@ -489,14 +489,13 @@ export class AdminResolver { event.setEventAdminContributionDelete(eventAdminContributionDelete), ) sendContributionRejectedEmail({ + firstName: user.firstName, + lastName: user.lastName, + email: user.emailContact.email, + language: user.language, senderFirstName: moderator.firstName, senderLastName: moderator.lastName, - recipientEmail: user.emailContact.email, - recipientFirstName: user.firstName, - recipientLastName: user.lastName, contributionMemo: contribution.memo, - contributionAmount: contribution.amount, - overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, }) return !!res diff --git a/backend/src/locales/de.json b/backend/src/locales/de.json index cca40d630..277728439 100644 --- a/backend/src/locales/de.json +++ b/backend/src/locales/de.json @@ -25,6 +25,11 @@ "contributionAmount": "Betrag: {contributionAmount} GDD", "subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt" }, + "contributionRejected": { + "commonGoodContributionRejected": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde von {senderFirstName} {senderLastName} abgelehnt.", + "subject": "Gradido: Dein Gemeinwohl-Beitrag wurde abgelehnt", + "toSeeContributionsAndMessages": "Um deine Gemeinwohl-Beiträge und dazugehörige Nachrichten zu sehen, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!" + }, "general": { "decimalSeparator": ",", "helloName": "Hallo {firstName} {lastName},", diff --git a/backend/src/locales/en.json b/backend/src/locales/en.json index 09cf61a9e..d4292b05f 100644 --- a/backend/src/locales/en.json +++ b/backend/src/locales/en.json @@ -3,7 +3,7 @@ "addedContributionMessage": { "commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.", "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!" + "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!" }, "accountActivation": { "duration": "The link has a validity of {hours} hours and {minutes} minutes. If the validity of the link has already expired, you can have a new link sent to you here by entering your email address:", @@ -25,6 +25,11 @@ "contributionAmount": "Amount: {contributionAmount} GDD", "subject": "Gradido: Your common good contribution was confirmed" }, + "contributionRejected": { + "commonGoodContributionRejected": "your public good contribution “{contributionMemo}” was rejected by {senderFirstName} {senderLastName}.", + "subject": "Gradido: Your common good contribution was rejected", + "toSeeContributionsAndMessages": "To see your common good contributions and related messages, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!" + }, "general": { "decimalSeparator": ".", "helloName": "Hello {firstName} {lastName}",