mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +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 = {
|
||||
docName: 'emails',
|
||||
|
||||
browse: {
|
||||
options: [
|
||||
'limit',
|
||||
'fields',
|
||||
'filter',
|
||||
'order',
|
||||
'page'
|
||||
],
|
||||
permissions: true,
|
||||
async query(frame) {
|
||||
return await models.Email.findPage(frame.options);
|
||||
}
|
||||
},
|
||||
|
||||
read: {
|
||||
options: [
|
||||
'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() {
|
||||
return this.read;
|
||||
}
|
||||
|
@ -261,6 +261,7 @@ module.exports = function apiRoutes() {
|
||||
router.post('/email_preview/posts/:id', mw.authAdminApi, http(apiCanary.email_preview.sendTestEmail));
|
||||
|
||||
// ## Emails
|
||||
router.get('/emails', mw.authAdminApi, http(apiCanary.emails.browse));
|
||||
router.get('/emails/:id', mw.authAdminApi, http(apiCanary.emails.read));
|
||||
router.put('/emails/:id/retry', mw.authAdminApi, http(apiCanary.emails.retry));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user