import { VideoChannelCreate } from '../../shared/models'
import { AccountModel } from '../models/account/account'
import { VideoChannelModel } from '../models/video/video-channel'
-import { buildActorInstance, getVideoChannelActivityPubUrl } from './activitypub'
+import { buildActorInstance, federateVideoIfNeeded, getVideoChannelActivityPubUrl } from './activitypub'
+import { VideoModel } from '../models/video/video'
async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) {
const uuid = uuidv4()
- const url = getVideoChannelActivityPubUrl(uuid)
- // We use the name as uuid
- const actorInstance = buildActorInstance('Group', url, uuid, uuid)
+ const url = getVideoChannelActivityPubUrl(videoChannelInfo.name)
+ const actorInstance = buildActorInstance('Group', url, videoChannelInfo.name, uuid)
const actorInstanceCreated = await actorInstance.save({ transaction: t })
const videoChannelData = {
- name: videoChannelInfo.name,
+ name: videoChannelInfo.displayName,
description: videoChannelInfo.description,
support: videoChannelInfo.support,
accountId: account.id,
return videoChannelCreated
}
+async function federateAllVideosOfChannel (videoChannel: VideoChannelModel) {
+ const videoIds = await VideoModel.getAllIdsFromChannel(videoChannel)
+
+ for (const videoId of videoIds) {
+ const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
+
+ await federateVideoIfNeeded(video, false)
+ }
+}
+
// ---------------------------------------------------------------------------
export {
- createVideoChannel
+ createVideoChannel,
+ federateAllVideosOfChannel
}