X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmiddlewares%2Fvalidators%2Fthemes.ts;h=d4716257f9a093791eaba1e5ccba60037e5fc885;hb=c756bae079e02873f6433582ca14a092fec0db27;hp=642f2df78fbc8589695ed225bdaa98869a13419f;hpb=345da516fae80f24c90c2196e96393b489af2243;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts index 642f2df78..d4716257f 100644 --- a/server/middlewares/validators/themes.ts +++ b/server/middlewares/validators/themes.ts @@ -1,10 +1,11 @@ import * as express from 'express' -import { param } from 'express-validator/check' -import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' +import { param } from 'express-validator' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { isSafePath } from '../../helpers/custom-validators/misc' import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' +import { logger } from '../../helpers/logger' import { PluginManager } from '../../lib/plugins/plugin-manager' -import { isSafePath } from '../../helpers/custom-validators/misc' +import { areValidationErrors } from './shared' const serveThemeCSSValidator = [ param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'), @@ -16,14 +17,20 @@ const serveThemeCSSValidator = [ if (areValidationErrors(req, res)) return - const theme = PluginManager.Instance.getRegisteredTheme(req.params.themeName) + const theme = PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName) if (!theme || theme.version !== req.params.themeVersion) { - return res.sendStatus(404) + return res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'No theme named ' + req.params.themeName + ' was found with version ' + req.params.themeVersion + }) } if (theme.css.includes(req.params.staticEndpoint) === false) { - return res.sendStatus(404) + return res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'No static endpoint was found for this theme' + }) } res.locals.registeredPlugin = theme