diff options
Diffstat (limited to 'server/middlewares')
-rw-r--r-- | server/middlewares/validators/plugins.ts | 30 | ||||
-rw-r--r-- | server/middlewares/validators/sort.ts | 3 |
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 | |||
8 | import { PluginModel } from '../../models/server/plugin' | 8 | import { PluginModel } from '../../models/server/plugin' |
9 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' | 9 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/install-plugin.model' |
10 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 10 | import { PluginType } from '../../../shared/models/plugins/plugin.type' |
11 | import { CONFIG } from '../../initializers/config' | ||
11 | 12 | ||
12 | const servePluginStaticDirectoryValidator = (pluginType: PluginType) => [ | 13 | const 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 | ||
35 | const listPluginsValidator = [ | 36 | const 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 | ||
123 | const 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 | ||
124 | export { | 151 | export { |
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 | |||
22 | const SORTABLE_USER_NOTIFICATIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_NOTIFICATIONS) | 22 | const SORTABLE_USER_NOTIFICATIONS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.USER_NOTIFICATIONS) |
23 | const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS) | 23 | const SORTABLE_VIDEO_PLAYLISTS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.VIDEO_PLAYLISTS) |
24 | const SORTABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.PLUGINS) | 24 | const SORTABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.PLUGINS) |
25 | const SORTABLE_AVAILABLE_PLUGINS_COLUMNS = createSortableColumns(SORTABLE_COLUMNS.AVAILABLE_PLUGINS) | ||
25 | 26 | ||
26 | const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) | 27 | const usersSortValidator = checkSort(SORTABLE_USERS_COLUMNS) |
27 | const accountsSortValidator = checkSort(SORTABLE_ACCOUNTS_COLUMNS) | 28 | const accountsSortValidator = checkSort(SORTABLE_ACCOUNTS_COLUMNS) |
@@ -43,6 +44,7 @@ const serversBlocklistSortValidator = checkSort(SORTABLE_SERVERS_BLOCKLIST_COLUM | |||
43 | const userNotificationsSortValidator = checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS) | 44 | const userNotificationsSortValidator = checkSort(SORTABLE_USER_NOTIFICATIONS_COLUMNS) |
44 | const videoPlaylistsSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS) | 45 | const videoPlaylistsSortValidator = checkSort(SORTABLE_VIDEO_PLAYLISTS_COLUMNS) |
45 | const pluginsSortValidator = checkSort(SORTABLE_PLUGINS_COLUMNS) | 46 | const pluginsSortValidator = checkSort(SORTABLE_PLUGINS_COLUMNS) |
47 | const 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, |