From 5ed27933694566f323352cdc975a7e0a7e0c3735 Mon Sep 17 00:00:00 2001 From: Sanne de Vries <65487235+sanne-san@users.noreply.github.com> Date: Mon, 5 Aug 2024 13:43:24 +0200 Subject: [PATCH] Added publication icon to donation notification email (#20704) REF MOM-317 - Added site icon to add some flair and personal branding to the donation notification email. --- .../core/core/server/services/staff/index.js | 2 + ghost/staff-service/lib/StaffService.js | 3 +- ghost/staff-service/lib/StaffServiceEmails.js | 8 +++- .../lib/email-templates/donation.hbs | 44 ++++++++++++------- .../staff-service/test/staff-service.test.js | 9 ++++ 5 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ghost/core/core/server/services/staff/index.js b/ghost/core/core/server/services/staff/index.js index 2b57d20de6..56c08cab2d 100644 --- a/ghost/core/core/server/services/staff/index.js +++ b/ghost/core/core/server/services/staff/index.js @@ -17,6 +17,7 @@ class StaffServiceWrapper { const mailer = new GhostMailer(); const settingsCache = require('../../../shared/settings-cache'); const urlUtils = require('../../../shared/url-utils'); + const {blogIcon} = require('../../../server/lib/image'); const settingsHelpers = require('../settings-helpers'); this.api = new StaffService({ @@ -26,6 +27,7 @@ class StaffServiceWrapper { settingsHelpers, settingsCache, urlUtils, + blogIcon, DomainEvents, memberAttributionService: memberAttribution.service, labs diff --git a/ghost/staff-service/lib/StaffService.js b/ghost/staff-service/lib/StaffService.js index 02d4e1b4dd..ed48a4a860 100644 --- a/ghost/staff-service/lib/StaffService.js +++ b/ghost/staff-service/lib/StaffService.js @@ -4,7 +4,7 @@ const {MilestoneCreatedEvent} = require('@tryghost/milestones'); // @NOTE: 'StaffService' is a vague name that does not describe what it's actually doing. // Possibly, "StaffNotificationService" or "StaffEventNotificationService" would be a more accurate name class StaffService { - constructor({logging, models, mailer, settingsCache, settingsHelpers, urlUtils, DomainEvents, labs, memberAttributionService}) { + constructor({logging, models, mailer, settingsCache, settingsHelpers, urlUtils, blogIcon, DomainEvents, labs, memberAttributionService}) { this.logging = logging; this.labs = labs; /** @private */ @@ -22,6 +22,7 @@ class StaffService { settingsHelpers, settingsCache, urlUtils, + blogIcon, labs }); } diff --git a/ghost/staff-service/lib/StaffServiceEmails.js b/ghost/staff-service/lib/StaffServiceEmails.js index b107af3ee1..fa15117087 100644 --- a/ghost/staff-service/lib/StaffServiceEmails.js +++ b/ghost/staff-service/lib/StaffServiceEmails.js @@ -5,12 +5,13 @@ const glob = require('glob'); const {EmailAddressParser} = require('@tryghost/email-addresses'); class StaffServiceEmails { - constructor({logging, models, mailer, settingsHelpers, settingsCache, urlUtils, labs}) { + constructor({logging, models, mailer, settingsHelpers, settingsCache, blogIcon, urlUtils, labs}) { this.logging = logging; this.models = models; this.mailer = mailer; this.settingsHelpers = settingsHelpers; this.settingsCache = settingsCache; + this.blogIcon = blogIcon; this.urlUtils = urlUtils; this.labs = labs; @@ -44,6 +45,7 @@ class StaffServiceEmails { attributionUrl: attribution?.url || '', referrerSource: attribution?.referrerSource, siteTitle: this.settingsCache.get('title'), + siteIconUrl: this.blogIcon.getIconUrl(true), siteUrl: this.urlUtils.getSiteUrl(), siteDomain: this.siteDomain, accentColor: this.settingsCache.get('accent_color'), @@ -103,6 +105,7 @@ class StaffServiceEmails { offerData, subscriptionData, siteTitle: this.settingsCache.get('title'), + siteIconUrl: this.blogIcon.getIconUrl(true), siteUrl: this.urlUtils.getSiteUrl(), siteDomain: this.siteDomain, accentColor: this.settingsCache.get('accent_color'), @@ -153,6 +156,7 @@ class StaffServiceEmails { tierData, subscriptionData, siteTitle: this.settingsCache.get('title'), + siteIconUrl: this.blogIcon.getIconUrl(true), siteUrl: this.urlUtils.getSiteUrl(), siteDomain: this.siteDomain, accentColor: this.settingsCache.get('accent_color'), @@ -182,6 +186,7 @@ class StaffServiceEmails { return { siteTitle: this.settingsCache.get('title'), + siteIconUrl: this.blogIcon.getIconUrl(true), siteUrl: this.urlUtils.getSiteUrl(), siteDomain: this.siteDomain, accentColor: this.settingsCache.get('accent_color'), @@ -282,6 +287,7 @@ class StaffServiceEmails { const templateData = { siteTitle: this.settingsCache.get('title'), siteUrl: this.urlUtils.getSiteUrl(), + siteIconUrl: this.blogIcon.getIconUrl(true), siteDomain: this.siteDomain, fromEmail: this.fromEmailAddress, toEmail: to, diff --git a/ghost/staff-service/lib/email-templates/donation.hbs b/ghost/staff-service/lib/email-templates/donation.hbs index 88b1e07a8f..35a33fc398 100644 --- a/ghost/staff-service/lib/email-templates/donation.hbs +++ b/ghost/staff-service/lib/email-templates/donation.hbs @@ -21,21 +21,33 @@
+ | |||||||
- Cha-ching! 💰 You received {{donation.amount}} from {{donation.name}}.-
- | This message was sent from {{siteDomain}} to {{toEmail}} +
+ |
This message was sent from {{siteDomain}} to {{toEmail}}
- | Don’t want to receive these emails? Manage your preferences here. +
+ |
Don’t want to receive these emails? Manage your preferences here. |