mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added email preview controller
This commit is contained in:
parent
61af0e08ae
commit
8a7bf353d4
1 changed files with 36 additions and 0 deletions
36
core/server/api/canary/email-preview.js
Normal file
36
core/server/api/canary/email-preview.js
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue