aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/videos/video-channel-sync.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares/validators/videos/video-channel-sync.ts')
-rw-r--r--server/middlewares/validators/videos/video-channel-sync.ts16
1 files changed, 3 insertions, 13 deletions
diff --git a/server/middlewares/validators/videos/video-channel-sync.ts b/server/middlewares/validators/videos/video-channel-sync.ts
index b18498243..081f09bba 100644
--- a/server/middlewares/validators/videos/video-channel-sync.ts
+++ b/server/middlewares/validators/videos/video-channel-sync.ts
@@ -3,10 +3,10 @@ import { body, param } from 'express-validator'
3import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' 3import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
4import { logger } from '@server/helpers/logger' 4import { logger } from '@server/helpers/logger'
5import { CONFIG } from '@server/initializers/config' 5import { CONFIG } from '@server/initializers/config'
6import { VideoChannelModel } from '@server/models/video/video-channel'
7import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' 6import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync'
8import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models' 7import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models'
9import { areValidationErrors, doesVideoChannelIdExist } from '../shared' 8import { areValidationErrors, doesVideoChannelIdExist } from '../shared'
9import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs'
10 10
11export const ensureSyncIsEnabled = (req: express.Request, res: express.Response, next: express.NextFunction) => { 11export const ensureSyncIsEnabled = (req: express.Request, res: express.Response, next: express.NextFunction) => {
12 if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) { 12 if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) {
@@ -48,18 +48,8 @@ export const ensureSyncExists = [
48 async (req: express.Request, res: express.Response, next: express.NextFunction) => { 48 async (req: express.Request, res: express.Response, next: express.NextFunction) => {
49 if (areValidationErrors(req, res)) return 49 if (areValidationErrors(req, res)) return
50 50
51 const syncId = parseInt(req.params.id, 10) 51 if (!await doesVideoChannelSyncIdExist(+req.params.id, res)) return
52 const sync = await VideoChannelSyncModel.loadWithChannel(syncId) 52 if (!await doesVideoChannelIdExist(res.locals.videoChannelSync.videoChannelId, res)) return
53
54 if (!sync) {
55 return res.fail({
56 status: HttpStatusCode.NOT_FOUND_404,
57 message: 'Synchronization not found'
58 })
59 }
60
61 res.locals.videoChannelSync = sync
62 res.locals.videoChannel = await VideoChannelModel.loadAndPopulateAccount(sync.videoChannelId)
63 53
64 return next() 54 return next()
65 } 55 }