Added plaintext field to email preview response

This commit is contained in:
Nazar Gargol 2019-11-05 15:04:48 +07:00
parent d1812281f7
commit 5d76ceef8b
2 changed files with 5 additions and 3 deletions

View File

@ -19,7 +19,8 @@ module.exports = {
],
permissions: true,
query(frame) {
return models.Post.findOne(frame.data, frame.options)
const options = Object.assign(frame.options, {formats: 'html,plaintext'});
return models.Post.findOne(frame.data, options)
.then((model) => {
if (!model) {
throw new common.errors.NotFoundError({
@ -27,7 +28,7 @@ module.exports = {
});
}
const post = model.toJSON();
const post = model.toJSON(options);
return mega.postEmailSerializer.serialize(post);
});

View File

@ -12,7 +12,8 @@ const getSite = () => {
const serialize = (post) => {
return {
subject: post.email_subject || post.title,
html: juice(template({post, site: getSite()}))
html: juice(template({post, site: getSite()})),
plaintext: post.plaintext
};
};