1 import * as Sequelize from 'sequelize'
2 import { VideoChannelCreate } from '../../shared/models'
3 import { AccountModel } from '../models/account/account'
4 import { VideoChannelModel } from '../models/video/video-channel'
5 import { getVideoChannelActivityPubUrl } from './activitypub'
7 async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) {
8 const videoChannelData = {
9 name: videoChannelInfo.name,
10 description: videoChannelInfo.description,
15 const videoChannel = VideoChannelModel.build(videoChannelData)
16 videoChannel.set('url', getVideoChannelActivityPubUrl(videoChannel))
18 const options = { transaction: t }
20 const videoChannelCreated = await videoChannel.save(options)
22 // Do not forget to add Account information to the created video channel
23 videoChannelCreated.Account = account
25 // No need to seed this empty video channel to followers
26 return videoChannelCreated
29 // ---------------------------------------------------------------------------