From a2431b7dcbc72c05101dcdbe631ff84a823aeb51 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 27 Nov 2017 17:30:46 +0100 Subject: Refractor validators --- server/controllers/api/videos/abuse.ts | 2 +- server/controllers/api/videos/blacklist.ts | 4 ++-- server/controllers/api/videos/channel.ts | 12 ++++++------ server/controllers/api/videos/index.ts | 8 ++++---- server/controllers/api/videos/rate.ts | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts index 88b3d538d..29e1175c5 100644 --- a/server/controllers/api/videos/abuse.ts +++ b/server/controllers/api/videos/abuse.ts @@ -33,7 +33,7 @@ abuseVideoRouter.get('/abuse', ) abuseVideoRouter.post('/:id/abuse', authenticate, - videoAbuseReportValidator, + asyncMiddleware(videoAbuseReportValidator), asyncMiddleware(reportVideoAbuseRetryWrapper) ) diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index be7cf6ea4..06333c271 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts @@ -21,7 +21,7 @@ const blacklistRouter = express.Router() blacklistRouter.post('/:videoId/blacklist', authenticate, ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), - videosBlacklistAddValidator, + asyncMiddleware(videosBlacklistAddValidator), asyncMiddleware(addVideoToBlacklist) ) @@ -38,7 +38,7 @@ blacklistRouter.get('/blacklist', blacklistRouter.delete('/:videoId/blacklist', authenticate, ensureUserHasRight(UserRight.MANAGE_VIDEO_BLACKLIST), - videosBlacklistRemoveValidator, + asyncMiddleware(videosBlacklistRemoveValidator), asyncMiddleware(removeVideoFromBlacklistController) ) diff --git a/server/controllers/api/videos/channel.ts b/server/controllers/api/videos/channel.ts index ce2656e71..d99f47c32 100644 --- a/server/controllers/api/videos/channel.ts +++ b/server/controllers/api/videos/channel.ts @@ -3,6 +3,7 @@ import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared' import { getFormattedObjects, logger, resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers' import { database as db } from '../../../initializers' import { createVideoChannel } from '../../../lib' +import { sendUpdateVideoChannel } from '../../../lib/activitypub/send/send-update' import { asyncMiddleware, authenticate, @@ -10,14 +11,13 @@ import { paginationValidator, setPagination, setVideoChannelsSort, - videoChannelsGetValidator, videoChannelsAddValidator, + videoChannelsGetValidator, videoChannelsRemoveValidator, videoChannelsSortValidator, videoChannelsUpdateValidator } from '../../../middlewares' import { AccountInstance, VideoChannelInstance } from '../../../models' -import { sendUpdateVideoChannel } from '../../../lib/activitypub/send/send-update' const videoChannelRouter = express.Router() @@ -30,7 +30,7 @@ videoChannelRouter.get('/channels', ) videoChannelRouter.get('/accounts/:accountId/channels', - listVideoAccountChannelsValidator, + asyncMiddleware(listVideoAccountChannelsValidator), asyncMiddleware(listVideoAccountChannels) ) @@ -42,18 +42,18 @@ videoChannelRouter.post('/channels', videoChannelRouter.put('/channels/:id', authenticate, - videoChannelsUpdateValidator, + asyncMiddleware(videoChannelsUpdateValidator), updateVideoChannelRetryWrapper ) videoChannelRouter.delete('/channels/:id', authenticate, - videoChannelsRemoveValidator, + asyncMiddleware(videoChannelsRemoveValidator), asyncMiddleware(removeVideoChannelRetryWrapper) ) videoChannelRouter.get('/channels/:id', - videoChannelsGetValidator, + asyncMiddleware(videoChannelsGetValidator), asyncMiddleware(getVideoChannel) ) diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 2b5afd632..244d91914 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -86,7 +86,7 @@ videosRouter.get('/', ) videosRouter.put('/:id', authenticate, - videosUpdateValidator, + asyncMiddleware(videosUpdateValidator), asyncMiddleware(updateVideoRetryWrapper) ) videosRouter.post('/upload', @@ -97,17 +97,17 @@ videosRouter.post('/upload', ) videosRouter.get('/:id/description', - videosGetValidator, + asyncMiddleware(videosGetValidator), asyncMiddleware(getVideoDescription) ) videosRouter.get('/:id', - videosGetValidator, + asyncMiddleware(videosGetValidator), getVideo ) videosRouter.delete('/:id', authenticate, - videosRemoveValidator, + asyncMiddleware(videosRemoveValidator), asyncMiddleware(removeVideoRetryWrapper) ) diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 134284df7..0c6a988cf 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -12,7 +12,7 @@ const rateVideoRouter = express.Router() rateVideoRouter.put('/:id/rate', authenticate, - videoRateValidator, + asyncMiddleware(videoRateValidator), asyncMiddleware(rateVideoRetryWrapper) ) -- cgit v1.2.3