2
1
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2023-12-13 21:00:40 +01:00

Added email preview controller

This commit is contained in:
Nazar Gargol 2019-11-05 12:14:26 +07:00
parent 61af0e08ae
commit 8a7bf353d4

View file

@ -0,0 +1,36 @@
const models = require('../../models');
const common = require('../../lib/common');
const mega = require('../../services/mega');
module.exports = {
docName: 'email_preview',
read: {
options: [
'fields'
],
validation: {
options: {
fields: ['html', 'plaintext', 'subject']
}
},
data: [
'id'
],
permissions: true,
query(frame) {
return models.Post.findOne(frame.data, frame.options)
.then((model) => {
if (!model) {
throw new common.errors.NotFoundError({
message: common.i18n.t('errors.api.posts.postNotFound')
});
}
const post = model.toJSON();
return mega.postEmailSerializer.serialize(post);
});
}
}
};