mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-04 17:04:59 +03:00
7ab4c44475
refs https://github.com/TryGhost/Team/issues/1071 Going forward, if the visibility of a page/post is set for specific tiers, we send a `tiers` array in API response that contains list of tiers with access. This change - - updates post/page mapper to transform existing data where `visibility` is a custom nql string to tiers array - updates default include for post/pages to include `products`, which allows attaching relevant tiers from the pivot table - cleans up usage of `visibility_filter` in serialization
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
JavaScript
const tpl = require('@tryghost/tpl');
|
|
const errors = require('@tryghost/errors');
|
|
const models = require('../../models');
|
|
const ALLOWED_INCLUDES = ['authors', 'tags', 'tiers'];
|
|
|
|
const messages = {
|
|
postNotFound: 'Post not found.'
|
|
};
|
|
|
|
module.exports = {
|
|
docName: 'email_post',
|
|
|
|
read: {
|
|
permissions: true,
|
|
options: [
|
|
'include'
|
|
],
|
|
data: [
|
|
'uuid'
|
|
],
|
|
validation: {
|
|
options: {
|
|
include: {
|
|
values: ALLOWED_INCLUDES
|
|
}
|
|
},
|
|
data: {
|
|
uuid: {
|
|
required: true
|
|
}
|
|
}
|
|
},
|
|
async query(frame) {
|
|
const model = await models.Post.findOne(Object.assign(frame.data, {status: 'sent'}), frame.options);
|
|
|
|
if (!model) {
|
|
throw new errors.NotFoundError({
|
|
message: tpl(messages.postNotFound)
|
|
});
|
|
}
|
|
|
|
return model;
|
|
}
|
|
}
|
|
};
|