]>
Commit | Line | Data |
---|---|---|
2a491182 F |
1 | import { Job } from 'bullmq' |
2 | import { logger } from '@server/helpers/logger' | |
3 | import { CONFIG } from '@server/initializers/config' | |
4 | import { synchronizeChannel } from '@server/lib/sync-channel' | |
5 | import { VideoChannelModel } from '@server/models/video/video-channel' | |
6 | import { VideoChannelImportPayload } from '@shared/models' | |
7 | ||
8 | export async function processVideoChannelImport (job: Job) { | |
9 | const payload = job.data as VideoChannelImportPayload | |
10 | ||
11 | logger.info('Processing video channel import in job %s.', job.id) | |
12 | ||
13 | // Channel import requires only http upload to be allowed | |
14 | if (!CONFIG.IMPORT.VIDEOS.HTTP.ENABLED) { | |
15 | logger.error('Cannot import channel as the HTTP upload is disabled') | |
16 | return | |
17 | } | |
18 | ||
19 | if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) { | |
20 | logger.error('Cannot import channel as the synchronization is disabled') | |
21 | return | |
22 | } | |
23 | ||
24 | const videoChannel = await VideoChannelModel.loadAndPopulateAccount(payload.videoChannelId) | |
25 | ||
26 | try { | |
27 | logger.info(`Starting importing videos from external channel "${payload.externalChannelUrl}" to "${videoChannel.name}" `) | |
28 | ||
29 | await synchronizeChannel({ | |
30 | channel: videoChannel, | |
31 | externalChannelUrl: payload.externalChannelUrl | |
32 | }) | |
33 | } catch (err) { | |
34 | logger.error(`Failed to import channel ${videoChannel.name}`, { err }) | |
35 | } | |
36 | } |