From 25f4974846292d21abcfdb3032154cc901f8ba6d Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Fri, 17 Mar 2023 09:01:35 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20comment=20CTA=20in=20newsle?= =?UTF-8?q?tters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes https://github.com/TryGhost/Team/issues/2672 - Moves the feature from behind the flag - Also hides the comment CTA for email only posts Co-authored-by: Sanne de Vries --- ghost/core/core/frontend/helpers/comments.js | 2 +- ghost/email-service/lib/email-renderer.js | 4 +++- ghost/email-service/test/email-renderer.test.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ghost/core/core/frontend/helpers/comments.js b/ghost/core/core/frontend/helpers/comments.js index 4c80db2701..8cfa7d2f33 100644 --- a/ghost/core/core/frontend/helpers/comments.js +++ b/ghost/core/core/frontend/helpers/comments.js @@ -73,7 +73,7 @@ module.exports = async function comments(options) { const dataAttributes = getDataAttributes(data); return new SafeString(` - +
`); }; diff --git a/ghost/email-service/lib/email-renderer.js b/ghost/email-service/lib/email-renderer.js index b96a436b09..9ff9900766 100644 --- a/ghost/email-service/lib/email-renderer.js +++ b/ghost/email-service/lib/email-renderer.js @@ -590,6 +590,8 @@ class EmailRenderer { const commentUrl = new URL(postUrl); commentUrl.hash = '#ghost-comments-root'; + const hasEmailOnlyFlag = post.related('posts_meta')?.get('email_only') ?? false; + const data = { site: { title: this.#settingsCache.get('title'), @@ -617,7 +619,7 @@ class EmailRenderer { newsletter: { name: newsletter.get('name'), showPostTitleSection: newsletter.get('show_post_title_section'), - showCommentCta: newsletter.get('show_comment_cta') && this.#settingsCache.get('comments_enabled') !== 'off' && this.#labs.isSet('makingItRain'), + showCommentCta: newsletter.get('show_comment_cta') && this.#settingsCache.get('comments_enabled') !== 'off' && !hasEmailOnlyFlag, showSubscriptionDetails: newsletter.get('show_subscription_details') && this.#labs.isSet('makingItRain') }, diff --git a/ghost/email-service/test/email-renderer.test.js b/ghost/email-service/test/email-renderer.test.js index 2d7939ca10..c266391d78 100644 --- a/ghost/email-service/test/email-renderer.test.js +++ b/ghost/email-service/test/email-renderer.test.js @@ -1089,7 +1089,7 @@ describe('Email renderer', function () { }); }); - it('show comment CTA is disabled if labs disabled', async function () { + it('show comment CTA is enabled if labs disabled', async function () { labsEnabled = false; settings.comments_enabled = 'all'; const html = ''; @@ -1105,7 +1105,7 @@ describe('Email renderer', function () { show_comment_cta: true }); const data = await emailRenderer.getTemplateData({post, newsletter, html, addPaywall: false}); - assert.equal(data.newsletter.showCommentCta, false); + assert.equal(data.newsletter.showCommentCta, true); }); it('show comment CTA is disabled if comments disabled', async function () {