From 012580d98f489e599d44a9a2a0bdc892b9455a90 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 May 2021 10:21:39 +0200 Subject: Cleanup We must not expose private actor objects to clients Just make 2 GET requests on channel/accounts instead --- server/middlewares/validators/actor.ts | 59 ---------------------------------- server/middlewares/validators/index.ts | 1 - 2 files changed, 60 deletions(-) delete mode 100644 server/middlewares/validators/actor.ts (limited to 'server/middlewares/validators') diff --git a/server/middlewares/validators/actor.ts b/server/middlewares/validators/actor.ts deleted file mode 100644 index 99b529dd6..000000000 --- a/server/middlewares/validators/actor.ts +++ /dev/null @@ -1,59 +0,0 @@ -import * as express from 'express' -import { param } from 'express-validator' -import { isActorNameValid } from '../../helpers/custom-validators/actor' -import { logger } from '../../helpers/logger' -import { areValidationErrors } from './utils' -import { - doesAccountNameWithHostExist, - doesLocalAccountNameExist, - doesVideoChannelNameWithHostExist, - doesLocalVideoChannelNameExist -} from '../../helpers/middlewares' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' - -const localActorValidator = [ - param('actorName').custom(isActorNameValid).withMessage('Should have a valid actor name'), - - async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking localActorValidator parameters', { parameters: req.params }) - - if (areValidationErrors(req, res)) return - - const isAccount = await doesLocalAccountNameExist(req.params.actorName, res, false) - const isVideoChannel = await doesLocalVideoChannelNameExist(req.params.actorName, res, false) - - if (!isAccount || !isVideoChannel) { - res.status(HttpStatusCode.NOT_FOUND_404) - .json({ error: 'Actor not found' }) - } - - return next() - } -] - -const actorNameWithHostGetValidator = [ - param('actorName').exists().withMessage('Should have an actor name with host'), - - async (req: express.Request, res: express.Response, next: express.NextFunction) => { - logger.debug('Checking actorNameWithHostGetValidator parameters', { parameters: req.params }) - - if (areValidationErrors(req, res)) return - - const isAccount = await doesAccountNameWithHostExist(req.params.actorName, res, false) - const isVideoChannel = await doesVideoChannelNameWithHostExist(req.params.actorName, res, false) - - if (!isAccount && !isVideoChannel) { - res.status(HttpStatusCode.NOT_FOUND_404) - .json({ error: 'Actor not found' }) - } - - return next() - } -] - -// --------------------------------------------------------------------------- - -export { - localActorValidator, - actorNameWithHostGetValidator -} diff --git a/server/middlewares/validators/index.ts b/server/middlewares/validators/index.ts index 3e1a1e5ce..24faeea3e 100644 --- a/server/middlewares/validators/index.ts +++ b/server/middlewares/validators/index.ts @@ -1,6 +1,5 @@ export * from './abuse' export * from './account' -export * from './actor' export * from './actor-image' export * from './blocklist' export * from './oembed' -- cgit v1.2.3