From a4071295460fdd44fc67872538d88d7486f9d047 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Thu, 10 Aug 2023 14:21:29 +0200 Subject: [PATCH] Added memberdata to donation emails (#17676) no issue --- ghost/staff-service/lib/StaffServiceEmails.js | 11 +++++++++-- .../lib/email-templates/donation.hbs | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/ghost/staff-service/lib/StaffServiceEmails.js b/ghost/staff-service/lib/StaffServiceEmails.js index b0303b3649..c8c440a280 100644 --- a/ghost/staff-service/lib/StaffServiceEmails.js +++ b/ghost/staff-service/lib/StaffServiceEmails.js @@ -254,6 +254,11 @@ class StaffServiceEmails { const formattedAmount = this.getFormattedAmount({currency: donationPaymentEvent.currency, amount: donationPaymentEvent.amount / 100}); const subject = `💸 Received a donation of ${formattedAmount} from ${donationPaymentEvent.name ?? donationPaymentEvent.email}`; + const memberData = donationPaymentEvent.memberId ? this.getMemberData({ + id: donationPaymentEvent.memberId, + name: donationPaymentEvent.name ?? null, + email: donationPaymentEvent.email + }) : null; for (const user of users) { const to = user.email; @@ -270,7 +275,9 @@ class StaffServiceEmails { name: donationPaymentEvent.name ?? donationPaymentEvent.email, email: donationPaymentEvent.email, amount: formattedAmount - } + }, + memberData, + accentColor: this.settingsCache.get('accent_color') }; const {html, text} = await this.renderEmailTemplate('donation', templateData); @@ -304,7 +311,7 @@ class StaffServiceEmails { adminUrl: this.urlUtils.urlJoin(this.urlUtils.urlFor('admin', true), '#', `/members/${member.id}`), initials: this.extractInitials(name), location: this.getGeolocationData(member.geolocation), - createdAt: moment(member.created_at).format('D MMM YYYY') + createdAt: member.created_at ? moment(member.created_at).format('D MMM YYYY') : null }; } diff --git a/ghost/staff-service/lib/email-templates/donation.hbs b/ghost/staff-service/lib/email-templates/donation.hbs index c031076562..6149e4c98a 100644 --- a/ghost/staff-service/lib/email-templates/donation.hbs +++ b/ghost/staff-service/lib/email-templates/donation.hbs @@ -29,7 +29,24 @@

Congratulations!

-

You received a donation of {{donation.amount}} from {{donation.name}} ({{donation.email}}).

+

You received a donation of {{donation.amount}} from {{donation.name}} ({{donation.email}}).

+ {{#if memberData}} + + + + + + +
+ + + + + + +
View member
+
+ {{/if}}