From ff91b644fb1b063d0a8eff7492beb1a9bf7e4ce1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2022 14:49:50 +0100 Subject: Add ability to install alpha/beta/rc plugin --- server/middlewares/validators/plugins.ts | 13 +++++++++---- server/middlewares/validators/themes.ts | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 78c030333..64bef2648 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts @@ -4,7 +4,12 @@ import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { PluginType } from '../../../shared/models/plugins/plugin.type' import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' -import { isNpmPluginNameValid, isPluginNameValid, isPluginTypeValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' +import { + isNpmPluginNameValid, + isPluginNameValid, + isPluginStableOrUnstableVersionValid, + isPluginTypeValid +} from '../../helpers/custom-validators/plugins' import { CONFIG } from '../../initializers/config' import { PluginManager } from '../../lib/plugins/plugin-manager' import { PluginModel } from '../../models/server/plugin' @@ -19,7 +24,7 @@ const getPluginValidator = (pluginType: PluginType, withVersion = true) => { if (withVersion) { validators.push( param('pluginVersion') - .custom(isPluginVersionValid) + .custom(isPluginStableOrUnstableVersionValid) ) } @@ -113,7 +118,7 @@ const installOrUpdatePluginValidator = [ .custom(isNpmPluginNameValid), body('pluginVersion') .optional() - .custom(isPluginVersionValid), + .custom(isPluginStableOrUnstableVersionValid), body('path') .optional() .custom(isSafePath), @@ -185,7 +190,7 @@ const listAvailablePluginsValidator = [ .custom(isPluginTypeValid), query('currentPeerTubeEngine') .optional() - .custom(isPluginVersionValid), + .custom(isPluginStableOrUnstableVersionValid), (req: express.Request, res: express.Response, next: express.NextFunction) => { if (areValidationErrors(req, res)) return diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts index c130801a0..080b3e096 100644 --- a/server/middlewares/validators/themes.ts +++ b/server/middlewares/validators/themes.ts @@ -2,7 +2,7 @@ import express from 'express' import { param } from 'express-validator' import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' import { isSafePath } from '../../helpers/custom-validators/misc' -import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' +import { isPluginNameValid, isPluginStableOrUnstableVersionValid } from '../../helpers/custom-validators/plugins' import { PluginManager } from '../../lib/plugins/plugin-manager' import { areValidationErrors } from './shared' @@ -10,7 +10,7 @@ const serveThemeCSSValidator = [ param('themeName') .custom(isPluginNameValid), param('themeVersion') - .custom(isPluginVersionValid), + .custom(isPluginStableOrUnstableVersionValid), param('staticEndpoint') .custom(isSafePath), -- cgit v1.2.3