diff options
Diffstat (limited to 'server/lib/video-channel.ts')
-rw-r--r-- | server/lib/video-channel.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/server/lib/video-channel.ts b/server/lib/video-channel.ts index 0fe95ca09..ee0482c36 100644 --- a/server/lib/video-channel.ts +++ b/server/lib/video-channel.ts | |||
@@ -3,7 +3,8 @@ import * as uuidv4 from 'uuid/v4' | |||
3 | import { VideoChannelCreate } from '../../shared/models' | 3 | import { VideoChannelCreate } from '../../shared/models' |
4 | import { AccountModel } from '../models/account/account' | 4 | import { AccountModel } from '../models/account/account' |
5 | import { VideoChannelModel } from '../models/video/video-channel' | 5 | import { VideoChannelModel } from '../models/video/video-channel' |
6 | import { buildActorInstance, getVideoChannelActivityPubUrl } from './activitypub' | 6 | import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub' |
7 | import { VideoModel } from '../models/video/video' | ||
7 | 8 | ||
8 | async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) { | 9 | async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) { |
9 | const uuid = uuidv4() | 10 | const uuid = uuidv4() |
@@ -33,8 +34,19 @@ async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account | |||
33 | return videoChannelCreated | 34 | return videoChannelCreated |
34 | } | 35 | } |
35 | 36 | ||
37 | async function federateAllVideosOfChannel (videoChannel: VideoChannelModel) { | ||
38 | const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel) | ||
39 | |||
40 | for (const videoId of videoIds) { | ||
41 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId) | ||
42 | |||
43 | await federateVideoIfNeeded(video, false) | ||
44 | } | ||
45 | } | ||
46 | |||
36 | // --------------------------------------------------------------------------- | 47 | // --------------------------------------------------------------------------- |
37 | 48 | ||
38 | export { | 49 | export { |
39 | createVideoChannel | 50 | createVideoChannel, |
51 | federateAllVideosOfChannel | ||
40 | } | 52 | } |