diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-16 11:33:22 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 6702a1b2ccd666285dee9c72b5bace641d2fce8b (patch) | |
tree | 78b7125d664b6f6b6c993c4e8483e1bdd24a0a30 /server/controllers | |
parent | 503c6f440abc8f5924c38c4bd63591cb6cefacec (diff) | |
download | PeerTube-6702a1b2ccd666285dee9c72b5bace641d2fce8b.tar.gz PeerTube-6702a1b2ccd666285dee9c72b5bace641d2fce8b.tar.zst PeerTube-6702a1b2ccd666285dee9c72b5bace641d2fce8b.zip |
Add ability to search available plugins
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/plugins.ts | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 14675fdf3..114cc49b6 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts | |||
@@ -8,12 +8,13 @@ import { | |||
8 | setDefaultPagination, | 8 | setDefaultPagination, |
9 | setDefaultSort | 9 | setDefaultSort |
10 | } from '../../middlewares' | 10 | } from '../../middlewares' |
11 | import { pluginsSortValidator } from '../../middlewares/validators' | 11 | import { availablePluginsSortValidator, pluginsSortValidator } from '../../middlewares/validators' |
12 | import { PluginModel } from '../../models/server/plugin' | 12 | import { PluginModel } from '../../models/server/plugin' |
13 | import { UserRight } from '../../../shared/models/users' | 13 | import { UserRight } from '../../../shared/models/users' |
14 | import { | 14 | import { |
15 | existingPluginValidator, | 15 | existingPluginValidator, |
16 | installOrUpdatePluginValidator, | 16 | installOrUpdatePluginValidator, |
17 | listAvailablePluginsValidator, | ||
17 | listPluginsValidator, | 18 | listPluginsValidator, |
18 | uninstallPluginValidator, | 19 | uninstallPluginValidator, |
19 | updatePluginSettingsValidator | 20 | updatePluginSettingsValidator |
@@ -22,9 +23,22 @@ import { PluginManager } from '../../lib/plugins/plugin-manager' | |||
22 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' | 23 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' |
23 | import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model' | 24 | import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model' |
24 | import { logger } from '../../helpers/logger' | 25 | import { logger } from '../../helpers/logger' |
26 | import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index' | ||
27 | import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' | ||
25 | 28 | ||
26 | const pluginRouter = express.Router() | 29 | const pluginRouter = express.Router() |
27 | 30 | ||
31 | pluginRouter.get('/available', | ||
32 | authenticate, | ||
33 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | ||
34 | listAvailablePluginsValidator, | ||
35 | paginationValidator, | ||
36 | availablePluginsSortValidator, | ||
37 | setDefaultSort, | ||
38 | setDefaultPagination, | ||
39 | asyncMiddleware(listAvailablePlugins) | ||
40 | ) | ||
41 | |||
28 | pluginRouter.get('/', | 42 | pluginRouter.get('/', |
29 | authenticate, | 43 | authenticate, |
30 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), | 44 | ensureUserHasRight(UserRight.MANAGE_PLUGINS), |
@@ -88,10 +102,10 @@ export { | |||
88 | // --------------------------------------------------------------------------- | 102 | // --------------------------------------------------------------------------- |
89 | 103 | ||
90 | async function listPlugins (req: express.Request, res: express.Response) { | 104 | async function listPlugins (req: express.Request, res: express.Response) { |
91 | const type = req.query.type | 105 | const pluginType = req.query.pluginType |
92 | 106 | ||
93 | const resultList = await PluginModel.listForApi({ | 107 | const resultList = await PluginModel.listForApi({ |
94 | type, | 108 | pluginType, |
95 | start: req.query.start, | 109 | start: req.query.start, |
96 | count: req.query.count, | 110 | count: req.query.count, |
97 | sort: req.query.sort | 111 | sort: req.query.sort |
@@ -160,3 +174,11 @@ async function updatePluginSettings (req: express.Request, res: express.Response | |||
160 | 174 | ||
161 | return res.sendStatus(204) | 175 | return res.sendStatus(204) |
162 | } | 176 | } |
177 | |||
178 | async function listAvailablePlugins (req: express.Request, res: express.Response) { | ||
179 | const query: PeertubePluginIndexList = req.query | ||
180 | |||
181 | const resultList = await listAvailablePluginsFromIndex(query) | ||
182 | |||
183 | return res.json(resultList) | ||
184 | } | ||