From 5d76ceef8bf44e1e3633f00c9d7cd03f5fc82509 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Tue, 5 Nov 2019 15:04:48 +0700 Subject: [PATCH] Added plaintext field to email preview response --- core/server/api/canary/email-preview.js | 5 +++-- core/server/services/mega/post-email-serializer.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/server/api/canary/email-preview.js b/core/server/api/canary/email-preview.js index 0dbc70a8d2..32c15ec369 100644 --- a/core/server/api/canary/email-preview.js +++ b/core/server/api/canary/email-preview.js @@ -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); }); diff --git a/core/server/services/mega/post-email-serializer.js b/core/server/services/mega/post-email-serializer.js index cf75a1516c..ee3a9db9fd 100644 --- a/core/server/services/mega/post-email-serializer.js +++ b/core/server/services/mega/post-email-serializer.js @@ -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 }; };