From 11d1acb475b9d26e7d371351347639e12eeeb33b Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Thu, 31 Oct 2019 12:11:36 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20`plaintext`=20field=20be?= =?UTF-8?q?ing=20added=20as=20empty=20property=20when=20member=20post=20is?= =?UTF-8?q?=20requested?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue - Tests in previous commit uncovered a bug with unwanted field attached to the post response --- .../api/canary/utils/serializers/output/utils/post-gating.js | 4 +++- .../api/v2/utils/serializers/output/utils/post-gating.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/server/api/canary/utils/serializers/output/utils/post-gating.js b/core/server/api/canary/utils/serializers/output/utils/post-gating.js index 465cc22b23..0511856d40 100644 --- a/core/server/api/canary/utils/serializers/output/utils/post-gating.js +++ b/core/server/api/canary/utils/serializers/output/utils/post-gating.js @@ -7,7 +7,9 @@ const forPost = (attrs, frame) => { if (!memberHasAccess) { ['plaintext', 'html'].forEach((field) => { - attrs[field] = ''; + if (attrs[field] !== undefined) { + attrs[field] = ''; + } }); } } diff --git a/core/server/api/v2/utils/serializers/output/utils/post-gating.js b/core/server/api/v2/utils/serializers/output/utils/post-gating.js index 465cc22b23..0511856d40 100644 --- a/core/server/api/v2/utils/serializers/output/utils/post-gating.js +++ b/core/server/api/v2/utils/serializers/output/utils/post-gating.js @@ -7,7 +7,9 @@ const forPost = (attrs, frame) => { if (!memberHasAccess) { ['plaintext', 'html'].forEach((field) => { - attrs[field] = ''; + if (attrs[field] !== undefined) { + attrs[field] = ''; + } }); } }