0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

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
This commit is contained in:
Fabien 'egg' O'Carroll 2020-11-17 11:00:03 +00:00 committed by GitHub
parent f53ab0f52b
commit bfc152bede
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -505,13 +505,9 @@ 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 {
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
if (newStatus === 'draft' && this.hasChanged('status')) {