mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
Added new browse email endpoint
refs https://github.com/TryGhost/Ghost/issues/12633 Adds new `browse` endpoint for emails that allows Admin to check performance of newsletters over time and show stats on dashboard as primary usecase
This commit is contained in:
parent
12a1c60424
commit
0620ff6ae0
@ -6,6 +6,20 @@ const megaService = require('../../services/mega');
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
docName: 'emails',
|
docName: 'emails',
|
||||||
|
|
||||||
|
browse: {
|
||||||
|
options: [
|
||||||
|
'limit',
|
||||||
|
'fields',
|
||||||
|
'filter',
|
||||||
|
'order',
|
||||||
|
'page'
|
||||||
|
],
|
||||||
|
permissions: true,
|
||||||
|
async query(frame) {
|
||||||
|
return await models.Email.findPage(frame.options);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
read: {
|
read: {
|
||||||
options: [
|
options: [
|
||||||
'fields'
|
'fields'
|
||||||
|
@ -7,6 +7,15 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
browse(page, apiConfig, frame) {
|
||||||
|
const data = {
|
||||||
|
emails: page.data.map(model => mapper.mapEmail(model, frame)),
|
||||||
|
meta: page.meta
|
||||||
|
};
|
||||||
|
|
||||||
|
frame.response = data;
|
||||||
|
},
|
||||||
|
|
||||||
get retry() {
|
get retry() {
|
||||||
return this.read;
|
return this.read;
|
||||||
}
|
}
|
||||||
|
@ -261,6 +261,7 @@ module.exports = function apiRoutes() {
|
|||||||
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
|
// ## Emails
|
||||||
|
router.get('/emails', mw.authAdminApi, http(apiCanary.emails.browse));
|
||||||
router.get('/emails/:id', mw.authAdminApi, http(apiCanary.emails.read));
|
router.get('/emails/:id', mw.authAdminApi, http(apiCanary.emails.read));
|
||||||
router.put('/emails/:id/retry', mw.authAdminApi, http(apiCanary.emails.retry));
|
router.put('/emails/:id/retry', mw.authAdminApi, http(apiCanary.emails.retry));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user