From bfc152bedebeb0292ab785d38ab0520d833cd6f6 Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Tue, 17 Nov 2020 11:00:03 +0000 Subject: [PATCH] Fixed handling of email_recipient_filter option (#12369) no-issue This logic would assume that the option was always passed at the point of publishing the post, which is not the case for scheduled posts. Instead of setting the property to 'none' when the option is not present, we take the approach of ONLY setting the propery when 1. It is present and not 'none' 2. The post is being published or scheduled This means that scheduled posts will have the property set correctly, and any future publishing will leave the it in the original state --- core/server/models/post.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/core/server/models/post.js b/core/server/models/post.js index 3933c75415..becaddceb3 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -505,12 +505,8 @@ Post = ghostBookshelf.Model.extend({ } // email_recipient_filter is read-only and should only be set using a query param when publishing/scheduling - if (this.hasChanged('status') && (newStatus === 'published' || newStatus === 'scheduled')) { - if (typeof options.email_recipient_filter === 'undefined') { - this.set('email_recipient_filter', 'none'); - } else { - this.set('email_recipient_filter', options.email_recipient_filter); - } + if (options.email_recipient_filter && options.email_recipient_filter !== 'none' && this.hasChanged('status') && (newStatus === 'published' || newStatus === 'scheduled')) { + this.set('email_recipient_filter', options.email_recipient_filter); } // ensure draft posts have the email_recipient_filter reset unless an email has already been sent