From 62f2c4a2bf7818abf9ef2b8bb9a100dea76ed427 Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Wed, 14 Aug 2019 13:27:08 +0800 Subject: [PATCH] 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 --- core/server/api/canary/actions.js | 25 +++---------------- .../server/web/api/canary/admin/middleware.js | 1 + core/server/web/api/canary/admin/routes.js | 2 +- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/core/server/api/canary/actions.js b/core/server/api/canary/actions.js index 182bdee70f..e6558be7a5 100644 --- a/core/server/api/canary/actions.js +++ b/core/server/api/canary/actions.js @@ -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); } } diff --git a/core/server/web/api/canary/admin/middleware.js b/core/server/web/api/canary/admin/middleware.js index 0fd49f12fb..84cfde6d1b 100644 --- a/core/server/web/api/canary/admin/middleware.js +++ b/core/server/web/api/canary/admin/middleware.js @@ -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'], diff --git a/core/server/web/api/canary/admin/routes.js b/core/server/web/api/canary/admin/routes.js index 642b9f13c3..8010548cc2 100644 --- a/core/server/web/api/canary/admin/routes.js +++ b/core/server/web/api/canary/admin/routes.js @@ -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; };