aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-16 11:33:22 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commit6702a1b2ccd666285dee9c72b5bace641d2fce8b (patch)
tree78b7125d664b6f6b6c993c4e8483e1bdd24a0a30 /server/controllers
parent503c6f440abc8f5924c38c4bd63591cb6cefacec (diff)
downloadPeerTube-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.ts28
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'
11import { pluginsSortValidator } from '../../middlewares/validators' 11import { availablePluginsSortValidator, pluginsSortValidator } from '../../middlewares/validators'
12import { PluginModel } from '../../models/server/plugin' 12import { PluginModel } from '../../models/server/plugin'
13import { UserRight } from '../../../shared/models/users' 13import { UserRight } from '../../../shared/models/users'
14import { 14import {
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'
22import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 23import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
23import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model' 24import { ManagePlugin } from '../../../shared/models/plugins/manage-plugin.model'
24import { logger } from '../../helpers/logger' 25import { logger } from '../../helpers/logger'
26import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
25 28
26const pluginRouter = express.Router() 29const pluginRouter = express.Router()
27 30
31pluginRouter.get('/available',
32 authenticate,
33 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
34 listAvailablePluginsValidator,
35 paginationValidator,
36 availablePluginsSortValidator,
37 setDefaultSort,
38 setDefaultPagination,
39 asyncMiddleware(listAvailablePlugins)
40)
41
28pluginRouter.get('/', 42pluginRouter.get('/',
29 authenticate, 43 authenticate,
30 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 44 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
@@ -88,10 +102,10 @@ export {
88// --------------------------------------------------------------------------- 102// ---------------------------------------------------------------------------
89 103
90async function listPlugins (req: express.Request, res: express.Response) { 104async 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
178async 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}