Ghost/core/server/api/canary/email-post.js
Megharth Lakhataria 1e73f0b07a
Replaced i18n.t w/ tpl helper in email-post.js and email-preview.js (#13418)
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
2021-10-04 09:57:08 +01:00

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;
}
}
};