From a3b472a12ec6e57dbe2f650419f8064864686eab Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Aug 2022 11:51:13 +0200 Subject: Add ability to list imports of a channel sync --- server/middlewares/validators/shared/index.ts | 1 + .../validators/shared/video-channel-syncs.ts | 24 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 server/middlewares/validators/shared/video-channel-syncs.ts (limited to 'server/middlewares/validators/shared') diff --git a/server/middlewares/validators/shared/index.ts b/server/middlewares/validators/shared/index.ts index fa89d05f2..bbd03b248 100644 --- a/server/middlewares/validators/shared/index.ts +++ b/server/middlewares/validators/shared/index.ts @@ -4,6 +4,7 @@ export * from './utils' export * from './video-blacklists' export * from './video-captions' export * from './video-channels' +export * from './video-channel-syncs' export * from './video-comments' export * from './video-imports' export * from './video-ownerships' diff --git a/server/middlewares/validators/shared/video-channel-syncs.ts b/server/middlewares/validators/shared/video-channel-syncs.ts new file mode 100644 index 000000000..a6e51eb97 --- /dev/null +++ b/server/middlewares/validators/shared/video-channel-syncs.ts @@ -0,0 +1,24 @@ +import express from 'express' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' +import { HttpStatusCode } from '@shared/models' + +async function doesVideoChannelSyncIdExist (id: number, res: express.Response) { + const sync = await VideoChannelSyncModel.loadWithChannel(+id) + + if (!sync) { + res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'Video channel sync not found' + }) + return false + } + + res.locals.videoChannelSync = sync + return true +} + +// --------------------------------------------------------------------------- + +export { + doesVideoChannelSyncIdExist +} -- cgit v1.2.3