mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 13:52:10 +03:00
1e73f0b07a
refs: #13380 - this is to replace i18n.t with tpl because i18n.t is deprecated - Replaced i18n.t with tpl helper in email-post.js - Replaced i18n.t with tpl helper in email-preview.js
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'];
|
|
|
|
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;
|
|
}
|
|
}
|
|
};
|