mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Implemented GET /emails/:id
endpoint
This commit is contained in:
parent
1ed2598c3b
commit
ae14eb00f9
6 changed files with 55 additions and 1 deletions
33
core/server/api/canary/email.js
Normal file
33
core/server/api/canary/email.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -111,6 +111,10 @@ module.exports = {
|
||||||
return shared.pipeline(require('./email-preview'), localUtils);
|
return shared.pipeline(require('./email-preview'), localUtils);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get emails() {
|
||||||
|
return shared.pipeline(require('./email'), localUtils);
|
||||||
|
},
|
||||||
|
|
||||||
get site() {
|
get site() {
|
||||||
return shared.pipeline(require('./site'), localUtils);
|
return shared.pipeline(require('./site'), localUtils);
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
read(email, apiConfig, frame) {
|
||||||
|
frame.response = {
|
||||||
|
emails: [email]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
|
@ -105,5 +105,9 @@ module.exports = {
|
||||||
|
|
||||||
get email_preview() {
|
get email_preview() {
|
||||||
return require('./email-preview');
|
return require('./email-preview');
|
||||||
|
},
|
||||||
|
|
||||||
|
get emails() {
|
||||||
|
return require('./emails');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -255,6 +255,9 @@
|
||||||
"api_key": {
|
"api_key": {
|
||||||
"apiKeyNotFound": "API Key not found"
|
"apiKeyNotFound": "API Key not found"
|
||||||
},
|
},
|
||||||
|
"email": {
|
||||||
|
"emailNotFound": "Email not found."
|
||||||
|
},
|
||||||
"base": {
|
"base": {
|
||||||
"index": {
|
"index": {
|
||||||
"missingContext": "missing context"
|
"missingContext": "missing context"
|
||||||
|
|
|
@ -215,9 +215,12 @@ module.exports = function apiRoutes() {
|
||||||
// ## Actions
|
// ## Actions
|
||||||
router.get('/actions', mw.authAdminApi, http(apiCanary.actions.browse));
|
router.get('/actions', mw.authAdminApi, http(apiCanary.actions.browse));
|
||||||
|
|
||||||
// ## Emails
|
// ## Email Preview
|
||||||
router.get('/email_preview/posts/:id', mw.authAdminApi, http(apiCanary.email_preview.read));
|
router.get('/email_preview/posts/:id', mw.authAdminApi, http(apiCanary.email_preview.read));
|
||||||
router.post('/email_preview/posts/:id', mw.authAdminApi, http(apiCanary.email_preview.sendTestEmail));
|
router.post('/email_preview/posts/:id', mw.authAdminApi, http(apiCanary.email_preview.sendTestEmail));
|
||||||
|
|
||||||
|
// ## Emails
|
||||||
|
router.get('/emails/:id', mw.authAdminApi, http(apiCanary.emails.read));
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue