0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Handled default value in post for specific tier content visibility (#14121)

refs https://github.com/TryGhost/Team/issues/1071

Default visibility for a post when set to specific tiers needs special handling as data for specific tiers is stored as an array of tiers on a pivot table. This change handles the default visibility for a new post when set to specific tiers to generate the right default values in model.
This commit is contained in:
Rishabh Garg 2022-02-04 21:00:08 +05:30 committed by GitHub
parent 3cebde7279
commit f3119cbf77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,9 +54,20 @@ Post = ghostBookshelf.Model.extend({
*/
defaults: function defaults() {
let visibility = 'public';
if (settingsCache.get('default_content_visibility')) {
visibility = settingsCache.get('default_content_visibility');
let tiers = [];
const defaultContentVisibility = settingsCache.get('default_content_visibility');
if (defaultContentVisibility) {
if (defaultContentVisibility === 'tiers') {
const tiersData = settingsCache.get('default_content_visibility_tiers') || [];
visibility = 'tiers',
tiers = tiersData.map((tierId) => {
return {
id: tierId
};
});
} else if (defaultContentVisibility !== 'tiers') {
visibility = settingsCache.get('default_content_visibility');
}
}
return {
@ -64,6 +75,7 @@ Post = ghostBookshelf.Model.extend({
status: 'draft',
featured: false,
type: 'post',
tiers,
visibility: visibility,
email_recipient_filter: 'none'
};