mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
34 lines
843 B
JavaScript
34 lines
843 B
JavaScript
|
const models = require('../../models');
|
||
|
const common = require('../../lib/common');
|
||
|
|
||
|
module.exports = {
|
||
|
docName: 'emails',
|
||
|
|
||
|
read: {
|
||
|
options: [
|
||
|
'fields'
|
||
|
],
|
||
|
validation: {
|
||
|
options: {
|
||
|
fields: ['html', 'plaintext', 'subject']
|
||
|
}
|
||
|
},
|
||
|
data: [
|
||
|
'id'
|
||
|
],
|
||
|
permissions: true,
|
||
|
query(frame) {
|
||
|
return models.Email.findOne(frame.data, frame.options)
|
||
|
.then((model) => {
|
||
|
if (!model) {
|
||
|
throw new common.errors.NotFoundError({
|
||
|
message: common.i18n.t('errors.api.email.emailNotFound')
|
||
|
});
|
||
|
}
|
||
|
|
||
|
return model.toJSON(frame.options);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|