mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Updated canary actions endpoint
closes #11015 This simplifies the actions endpoint and allows for filtering and querying of all types of actions across separate resources and actors
This commit is contained in:
parent
ab70a369fa
commit
62f2c4a2bf
3 changed files with 5 additions and 23 deletions
|
@ -7,31 +7,12 @@ module.exports = {
|
|||
options: [
|
||||
'page',
|
||||
'limit',
|
||||
'fields'
|
||||
'fields',
|
||||
'include',
|
||||
'filter'
|
||||
],
|
||||
data: [
|
||||
'id',
|
||||
'type'
|
||||
],
|
||||
validation: {
|
||||
id: {
|
||||
required: true
|
||||
},
|
||||
type: {
|
||||
required: true,
|
||||
values: ['resource', 'actor']
|
||||
}
|
||||
},
|
||||
permissions: true,
|
||||
query(frame) {
|
||||
if (frame.data.type === 'resource') {
|
||||
frame.options.withRelated = ['actor'];
|
||||
frame.options.filter = `resource_id:${frame.data.id}`;
|
||||
} else {
|
||||
frame.options.withRelated = ['resource'];
|
||||
frame.options.filter = `actor_id:${frame.data.id}`;
|
||||
}
|
||||
|
||||
return models.Action.findPage(frame.options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ const notImplemented = function (req, res, next) {
|
|||
pages: ['GET', 'PUT', 'DELETE', 'POST'],
|
||||
images: ['POST'],
|
||||
// @NOTE: experimental
|
||||
actions: ['GET'],
|
||||
tags: ['GET', 'PUT', 'DELETE', 'POST'],
|
||||
users: ['GET'],
|
||||
themes: ['POST', 'PUT'],
|
||||
|
|
|
@ -222,7 +222,7 @@ module.exports = function apiRoutes() {
|
|||
router.get('/oembed', mw.authAdminApi, http(apiCanary.oembed.read));
|
||||
|
||||
// ## Actions
|
||||
router.get('/actions/:type/:id', mw.authAdminApi, http(apiCanary.actions.browse));
|
||||
router.get('/actions', mw.authAdminApi, http(apiCanary.actions.browse));
|
||||
|
||||
return router;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue