diff options
Diffstat (limited to 'server/middlewares/validators/videos/video-channel-sync.ts')
-rw-r--r-- | server/middlewares/validators/videos/video-channel-sync.ts | 16 |
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' | |||
3 | import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' | 3 | import { isUrlValid } from '@server/helpers/custom-validators/activitypub/misc' |
4 | import { logger } from '@server/helpers/logger' | 4 | import { logger } from '@server/helpers/logger' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
6 | import { VideoChannelModel } from '@server/models/video/video-channel' | ||
7 | import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' | 6 | import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' |
8 | import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models' | 7 | import { HttpStatusCode, VideoChannelSyncCreate } from '@shared/models' |
9 | import { areValidationErrors, doesVideoChannelIdExist } from '../shared' | 8 | import { areValidationErrors, doesVideoChannelIdExist } from '../shared' |
9 | import { doesVideoChannelSyncIdExist } from '../shared/video-channel-syncs' | ||
10 | 10 | ||
11 | export const ensureSyncIsEnabled = (req: express.Request, res: express.Response, next: express.NextFunction) => { | 11 | export 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 | } |