aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/validators/plugins.ts30
-rw-r--r--server/middlewares/validators/sort.ts3
2 files changed, 32 insertions, 1 deletions
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 8103ec7d3..8cb3153aa 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -8,6 +8,7 @@ import { isBooleanValid, isSafePath } from '../../helpers/custom-validators/misc
8import { PluginModel } from '../../models/server/plugin' 8import { PluginModel } from '../../models/server/plugin'
9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' 9import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model'
10import { PluginType } from '../../../shared/models/plugins/plugin.type' 10import { PluginType } from '../../../shared/models/plugins/plugin.type'
11import { CONFIG } from '../../initializers/config'
11 12
12const servePluginStaticDirectoryValidator = (pluginType: PluginType) => [ 13const servePluginStaticDirectoryValidator = (pluginType: PluginType) => [
13 param('pluginName').custom(isPluginNameValid).withMessage('Should have a valid plugin name'), 14 param('pluginName').custom(isPluginNameValid).withMessage('Should have a valid plugin name'),
@@ -33,7 +34,7 @@ const servePluginStaticDirectoryValidator = (pluginType: PluginType) => [
33] 34]
34 35
35const listPluginsValidator = [ 36const listPluginsValidator = [
36 query('type') 37 query('pluginType')
37 .optional() 38 .optional()
38 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'), 39 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
39 query('uninstalled') 40 query('uninstalled')
@@ -119,12 +120,39 @@ const updatePluginSettingsValidator = [
119 } 120 }
120] 121]
121 122
123const listAvailablePluginsValidator = [
124 query('sort')
125 .optional()
126 .exists().withMessage('Should have a valid sort'),
127 query('search')
128 .optional()
129 .exists().withMessage('Should have a valid search'),
130 query('pluginType')
131 .optional()
132 .custom(isPluginTypeValid).withMessage('Should have a valid plugin type'),
133
134 (req: express.Request, res: express.Response, next: express.NextFunction) => {
135 logger.debug('Checking enabledPluginValidator parameters', { parameters: req.query })
136
137 if (areValidationErrors(req, res)) return
138
139 if (CONFIG.PLUGINS.INDEX.ENABLED === false) {
140 return res.status(400)
141 .json({ error: 'Plugin index is not enabled' })
142 .end()
143 }
144
145 return next()
146 }
147]
148
122// --------------------------------------------------------------------------- 149// ---------------------------------------------------------------------------
123 150
124export { 151export {
125 servePluginStaticDirectoryValidator, 152 servePluginStaticDirectoryValidator,
126 updatePluginSettingsValidator, 153 updatePluginSettingsValidator,
127 uninstallPluginValidator, 154 uninstallPluginValidator,
155 listAvailablePluginsValidator,
128 existingPluginValidator, 156 existingPluginValidator,
129 installOrUpdatePluginValidator, 157 installOrUpdatePluginValidator,
130 listPluginsValidator 158 listPluginsValidator
diff --git a/server/middlewares/validators/sort.ts b/server/middlewares/validators/sort.ts
index 102db85cb..c75e701d6 100644
--- a/server/middlewares/validators/sort.ts
+++ b/server/middlewares/validators/sort.ts
@@ -22,6 +22,7 @@ const SORTABLE_SERVERS_BLOCKLIST_COLUMNS = createSortableColumns(SORTABLE_COLUMN
22const SORTABLE_USER_NOTIFICATIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_NOTIFICATIONS) 22const SORTABLE_USER_NOTIFICATIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_NOTIFICATIONS)
23const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS) 23const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS)
24const SORTABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.PLUGINS) 24const SORTABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.PLUGINS)
25const SORTABLE_AVAILABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.AVAILABLE_PLUGINS)
25 26
26const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) 27const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS)
27const accountsSortValidator = checkSort(SORTABLE_ACCOUNTS_COLUMNS) 28const accountsSortValidator = checkSort(SORTABLE_ACCOUNTS_COLUMNS)
@@ -43,6 +44,7 @@ const serversBlocklistSortValidator = checkSort(SORTABLE_SERVERS_BLOCKLIST_COLUM
43const userNotificationsSortValidator = checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS) 44const userNotificationsSortValidator = checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS)
44const videoPlaylistsSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS) 45const videoPlaylistsSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS)
45const pluginsSortValidator = checkSort(SORTABLE_PLUGINS_COLUMNS) 46const pluginsSortValidator = checkSort(SORTABLE_PLUGINS_COLUMNS)
47const availablePluginsSortValidator = checkSort(SORTABLE_AVAILABLE_PLUGINS_COLUMNS)
46 48
47// --------------------------------------------------------------------------- 49// ---------------------------------------------------------------------------
48 50
@@ -61,6 +63,7 @@ export {
61 videoCommentThreadsSortValidator, 63 videoCommentThreadsSortValidator,
62 videoRatesSortValidator, 64 videoRatesSortValidator,
63 userSubscriptionsSortValidator, 65 userSubscriptionsSortValidator,
66 availablePluginsSortValidator,
64 videoChannelsSearchSortValidator, 67 videoChannelsSearchSortValidator,
65 accountsBlocklistSortValidator, 68 accountsBlocklistSortValidator,
66 serversBlocklistSortValidator, 69 serversBlocklistSortValidator,