From 3048c7e790fa8e45631ca5c1506f6f44273f7647 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 7 Nov 2022 16:27:43 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20sending=20feedback?= =?UTF-8?q?=20on=20email=20only=20posts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes https://github.com/TryGhost/Team/issues/2220 `Post.findOne` is filtering by status 'published' by default. 'sent' isn't 'published' so we throw a 404 error when trying to send feedback to a 'sent' post. --- .../server/services/audience-feedback/FeedbackRepository.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghost/core/core/server/services/audience-feedback/FeedbackRepository.js b/ghost/core/core/server/services/audience-feedback/FeedbackRepository.js index 5aa0d623dc..7700c9e752 100644 --- a/ghost/core/core/server/services/audience-feedback/FeedbackRepository.js +++ b/ghost/core/core/server/services/audience-feedback/FeedbackRepository.js @@ -62,6 +62,6 @@ module.exports = class FeedbackRepository { } async getPostById(id) { - return await this.#Post.findOne({id}); + return await this.#Post.findOne({id, status: 'all'}); } }; From 2a2f5cca503dd2fdb3678ab1a2c505b23bb0d9b8 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 7 Nov 2022 16:55:17 +0100 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20source=20tracking=20?= =?UTF-8?q?using=20cached=20value=20(#15778)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://ghost.slack.com/archives/C02G9E68C/p1667834794676479 - When enabling tracking, it could be the case that the server is ignoring the attributions because of the cached setting value. - When disabling tracking, the frontend should take care of not collecting new tracking information to the server, but still the backend value should be used as a fail-safe. --- .../server/services/member-attribution/index.js | 2 +- ghost/member-attribution/lib/service.js | 10 +++++++--- ghost/member-attribution/test/service.test.js | 16 ++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/ghost/core/core/server/services/member-attribution/index.js b/ghost/core/core/server/services/member-attribution/index.js index 12f4888865..84c17e7fec 100644 --- a/ghost/core/core/server/services/member-attribution/index.js +++ b/ghost/core/core/server/services/member-attribution/index.js @@ -40,7 +40,7 @@ class MemberAttributionServiceWrapper { Integration: models.Integration }, attributionBuilder: this.attributionBuilder, - isTrackingEnabled: !!settingsCache.get('members_track_sources') + getTrackingEnabled: () => !!settingsCache.get('members_track_sources') }); } } diff --git a/ghost/member-attribution/lib/service.js b/ghost/member-attribution/lib/service.js index e2233a707a..5306e84e16 100644 --- a/ghost/member-attribution/lib/service.js +++ b/ghost/member-attribution/lib/service.js @@ -5,15 +5,19 @@ class MemberAttributionService { * * @param {Object} deps * @param {Object} deps.attributionBuilder - * @param {boolean} deps.isTrackingEnabled * @param {Object} deps.models * @param {Object} deps.models.MemberCreatedEvent * @param {Object} deps.models.SubscriptionCreatedEvent + * @param {() => boolean} deps.getTrackingEnabled */ - constructor({attributionBuilder, models, isTrackingEnabled}) { + constructor({attributionBuilder, models, getTrackingEnabled}) { this.models = models; this.attributionBuilder = attributionBuilder; - this.isTrackingEnabled = isTrackingEnabled; + this._getTrackingEnabled = getTrackingEnabled; + } + + get isTrackingEnabled() { + return this._getTrackingEnabled(); } /** diff --git a/ghost/member-attribution/test/service.test.js b/ghost/member-attribution/test/service.test.js index 101b4b02ce..34ac0d8a83 100644 --- a/ghost/member-attribution/test/service.test.js +++ b/ghost/member-attribution/test/service.test.js @@ -13,7 +13,7 @@ describe('MemberAttributionService', function () { describe('getAttributionFromContext', function () { it('returns null if no context is provided', async function () { const service = new MemberAttributionService({ - isTrackingEnabled: true + getTrackingEnabled: () => true }); const attribution = await service.getAttributionFromContext(); @@ -31,7 +31,7 @@ describe('MemberAttributionService', function () { it('returns attribution for importer context', async function () { const service = new MemberAttributionService({ - isTrackingEnabled: true + getTrackingEnabled: () => true }); const attribution = await service.getAttributionFromContext({importer: true}); @@ -40,7 +40,7 @@ describe('MemberAttributionService', function () { it('returns attribution for admin context', async function () { const service = new MemberAttributionService({ - isTrackingEnabled: true + getTrackingEnabled: () => true }); const attribution = await service.getAttributionFromContext({user: 'abc'}); @@ -49,7 +49,7 @@ describe('MemberAttributionService', function () { it('returns attribution for api without integration context', async function () { const service = new MemberAttributionService({ - isTrackingEnabled: true + getTrackingEnabled: () => true }); const attribution = await service.getAttributionFromContext({ api_key: 'abc' @@ -69,7 +69,7 @@ describe('MemberAttributionService', function () { } } }, - isTrackingEnabled: true + getTrackingEnabled: () => true }); const attribution = await service.getAttributionFromContext({ api_key: 'abc', @@ -96,7 +96,7 @@ describe('MemberAttributionService', function () { }; } }, - isTrackingEnabled: true + getTrackingEnabled: () => true }); const model = { id: 'event_id', @@ -130,7 +130,7 @@ describe('MemberAttributionService', function () { }; } }, - isTrackingEnabled: true + getTrackingEnabled: () => true }); const model = { id: 'event_id', @@ -170,7 +170,7 @@ describe('MemberAttributionService', function () { }; } }, - isTrackingEnabled: true + getTrackingEnabled: () => true }); const model = { id: 'event_id', From 5f9e354cae30ac9299fbb01ebe326b2a3491b449 Mon Sep 17 00:00:00 2001 From: Ghost CI <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 7 Nov 2022 16:13:40 +0000 Subject: [PATCH 3/3] v5.22.8 --- ghost/admin/package.json | 2 +- ghost/core/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/admin/package.json b/ghost/admin/package.json index 5e7e994901..602b9d2155 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -1,6 +1,6 @@ { "name": "ghost-admin", - "version": "5.22.7", + "version": "5.22.8", "description": "Ember.js admin client for Ghost", "author": "Ghost Foundation", "homepage": "http://ghost.org", diff --git a/ghost/core/package.json b/ghost/core/package.json index c051f939a9..5f5b8a1c06 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -1,6 +1,6 @@ { "name": "ghost", - "version": "5.22.7", + "version": "5.22.8", "description": "The professional publishing platform", "author": "Ghost Foundation", "homepage": "https://ghost.org",