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 --- .../lib/job-queue/handlers/video-channel-import.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/video-channel-import.ts b/server/lib/job-queue/handlers/video-channel-import.ts index 9bdb2d269..9aaad659e 100644 --- a/server/lib/job-queue/handlers/video-channel-import.ts +++ b/server/lib/job-queue/handlers/video-channel-import.ts @@ -3,6 +3,8 @@ import { logger } from '@server/helpers/logger' import { CONFIG } from '@server/initializers/config' import { synchronizeChannel } from '@server/lib/sync-channel' import { VideoChannelModel } from '@server/models/video/video-channel' +import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync' +import { MChannelSync } from '@server/types/models' import { VideoChannelImportPayload } from '@shared/models' export async function processVideoChannelImport (job: Job) { @@ -12,13 +14,20 @@ export async function processVideoChannelImport (job: Job) { // Channel import requires only http upload to be allowed if (!CONFIG.IMPORT.VIDEOS.HTTP.ENABLED) { - logger.error('Cannot import channel as the HTTP upload is disabled') - return + throw new Error('Cannot import channel as the HTTP upload is disabled') } if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) { - logger.error('Cannot import channel as the synchronization is disabled') - return + throw new Error('Cannot import channel as the synchronization is disabled') + } + + let channelSync: MChannelSync + if (payload.partOfChannelSyncId) { + channelSync = await VideoChannelSyncModel.loadWithChannel(payload.partOfChannelSyncId) + + if (!channelSync) { + throw new Error('Unlnown channel sync specified in videos channel import') + } } const videoChannel = await VideoChannelModel.loadAndPopulateAccount(payload.videoChannelId) @@ -28,7 +37,8 @@ export async function processVideoChannelImport (job: Job) { await synchronizeChannel({ channel: videoChannel, - externalChannelUrl: payload.externalChannelUrl + externalChannelUrl: payload.externalChannelUrl, + channelSync }) } catch (err) { logger.error(`Failed to import channel ${videoChannel.name}`, { err }) -- cgit v1.2.3