1 import * as Sequelize from 'sequelize'
2 import { VideoChannelCreate } from '../../shared/models'
3 import { database as db } from '../initializers'
4 import { AccountInstance } from '../models'
5 import { getVideoChannelActivityPubUrl } from './activitypub/url'
7 async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
8 const videoChannelData = {
9 name: videoChannelInfo.name,
10 description: videoChannelInfo.description,
15 const videoChannel = db.VideoChannel.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 // ---------------------------------------------------------------------------