From ce45571dc0712e56c39fe55dfa52686489e5c802 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Mon, 12 Dec 2022 11:40:42 +0530 Subject: [PATCH] Updated email faqs in portal to show sender email address refs https://github.com/TryGhost/Team/issues/2348 - updates email faqs to show the sender email from newsletter data --- .../content/__snapshots__/newsletters.test.js.snap | 10 ++++++++-- .../api/canary/utils/serializers/output/mapper.test.js | 1 + ghost/portal/src/components/pages/EmailReceivingFAQ.js | 10 +++++----- ghost/portal/src/utils/helpers.js | 8 ++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap b/ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap index 9c9d734e97..87f90d0925 100644 --- a/ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap +++ b/ghost/core/test/e2e-api/content/__snapshots__/newsletters.test.js.snap @@ -18,6 +18,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Default Newsletter", + "sender_email": null, "slug": "default-newsletter", "sort_order": 0, "subscribe_on_signup": true, @@ -30,6 +31,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Daily newsletter", + "sender_email": "jamie@example.com", "slug": "daily-newsletter", "sort_order": 1, "subscribe_on_signup": false, @@ -42,6 +44,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Weekly newsletter", + "sender_email": "jamie@example.com", "slug": "weekly-newsletter", "sort_order": 2, "subscribe_on_signup": true, @@ -57,7 +60,7 @@ exports[`Newsletters Content API Can request only active newsletters 2: [headers Object { "access-control-allow-origin": "*", "cache-control": "public, max-age=0", - "content-length": "1000", + "content-length": "1090", "content-type": "application/json; charset=utf-8", "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "vary": "Accept-Version, Accept-Encoding", @@ -83,6 +86,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Default Newsletter", + "sender_email": null, "slug": "default-newsletter", "sort_order": 0, "subscribe_on_signup": true, @@ -95,6 +99,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Daily newsletter", + "sender_email": "jamie@example.com", "slug": "daily-newsletter", "sort_order": 1, "subscribe_on_signup": false, @@ -107,6 +112,7 @@ Object { "description": null, "id": StringMatching /\\[a-f0-9\\]\\{24\\}/, "name": "Weekly newsletter", + "sender_email": "jamie@example.com", "slug": "weekly-newsletter", "sort_order": 2, "subscribe_on_signup": true, @@ -122,7 +128,7 @@ exports[`Newsletters Content API Cannot override filters to fetch archived newsl Object { "access-control-allow-origin": "*", "cache-control": "public, max-age=0", - "content-length": "1000", + "content-length": "1090", "content-type": "application/json; charset=utf-8", "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "vary": "Accept-Version, Accept-Encoding", diff --git a/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js b/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js index e8f8b1d880..4562266151 100644 --- a/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js +++ b/ghost/core/test/unit/api/canary/utils/serializers/output/mapper.test.js @@ -239,6 +239,7 @@ describe('Unit: utils/serializers/output/mappers', function () { name: newsletter.name, description: newsletter.description, slug: newsletter.slug, + sender_email: newsletter.sender_email, subscribe_on_signup: newsletter.subscribe_on_signup, visibility: newsletter.visibility, sort_order: newsletter.sort_order, diff --git a/ghost/portal/src/components/pages/EmailReceivingFAQ.js b/ghost/portal/src/components/pages/EmailReceivingFAQ.js index e6c31791c5..2259f09332 100644 --- a/ghost/portal/src/components/pages/EmailReceivingFAQ.js +++ b/ghost/portal/src/components/pages/EmailReceivingFAQ.js @@ -2,14 +2,14 @@ import AppContext from 'AppContext'; import {useContext} from 'react'; import BackButton from 'components/common/BackButton'; import CloseButton from 'components/common/CloseButton'; -import {getSupportAddress} from 'utils/helpers'; +import {getDefaultNewsletterSender, getSupportAddress} from 'utils/helpers'; export default function EmailReceivingPage() { const {brandColor, onAction, site, lastPage, member} = useContext(AppContext); const supportAddressEmail = getSupportAddress({site}); const supportAddress = `mailto:${supportAddressEmail}`; - + const defaultNewsletterSenderEmail = getDefaultNewsletterSender({site}); return (
@@ -38,15 +38,15 @@ export default function EmailReceivingPage() {

Create a new contact

-

In your email client add %newsletter@fromaddress.com% to your contacts list. This signals to your mail provider that emails sent from this address should be trusted.

+

In your email client add {defaultNewsletterSenderEmail} to your contacts list. This signals to your mail provider that emails sent from this address should be trusted.

Send an email and say hi!

-

Send an email to %newsletter@fromaddress.com% and say hello. This can also help signal to your mail provider that emails to-and-from this address should be trusted.

+

Send an email to {defaultNewsletterSenderEmail} and say hello. This can also help signal to your mail provider that emails to-and-from this address should be trusted.

Check with your mail provider

-

If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from %newsletter@fromaddress.com%

+

If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from {defaultNewsletterSenderEmail}

Get in touch for help

diff --git a/ghost/portal/src/utils/helpers.js b/ghost/portal/src/utils/helpers.js index 5b025ecd92..5191ad9770 100644 --- a/ghost/portal/src/utils/helpers.js +++ b/ghost/portal/src/utils/helpers.js @@ -692,6 +692,14 @@ export const getSupportAddress = ({site}) => { return supportAddress || ''; }; +export const getDefaultNewsletterSender = ({site}) => { + const newsletters = getSiteNewsletters({site}); + const defaultNewsletter = newsletters?.[0]; + if (defaultNewsletter) { + return defaultNewsletter.sender_email || `noreply@${getSiteDomain({site})}`; + } +}; + export const getSiteDomain = ({site}) => { try { return ((new URL(site.url)).origin).replace(/^http(s?):\/\//, '').replace(/\/$/, '');