2017-10-24 19:41:09 +02:00
|
|
|
import * as Sequelize from 'sequelize'
|
2017-11-17 15:52:26 +01:00
|
|
|
import { VideoChannelCreate } from '../../shared/models'
|
2017-12-12 17:53:50 +01:00
|
|
|
import { AccountModel } from '../models/account/account'
|
|
|
|
import { VideoChannelModel } from '../models/video/video-channel'
|
|
|
|
import { getVideoChannelActivityPubUrl } from './activitypub'
|
2017-10-24 19:41:09 +02:00
|
|
|
|
2017-12-12 17:53:50 +01:00
|
|
|
async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) {
|
2017-10-24 19:41:09 +02:00
|
|
|
const videoChannelData = {
|
|
|
|
name: videoChannelInfo.name,
|
|
|
|
description: videoChannelInfo.description,
|
|
|
|
remote: false,
|
2017-11-10 14:48:08 +01:00
|
|
|
accountId: account.id
|
2017-10-24 19:41:09 +02:00
|
|
|
}
|
|
|
|
|
2017-12-12 17:53:50 +01:00
|
|
|
const videoChannel = VideoChannelModel.build(videoChannelData)
|
2017-11-20 09:43:39 +01:00
|
|
|
videoChannel.set('url', getVideoChannelActivityPubUrl(videoChannel))
|
2017-11-14 10:57:56 +01:00
|
|
|
|
2017-10-24 19:41:09 +02:00
|
|
|
const options = { transaction: t }
|
|
|
|
|
2017-10-25 11:55:06 +02:00
|
|
|
const videoChannelCreated = await videoChannel.save(options)
|
|
|
|
|
2017-11-09 17:51:58 +01:00
|
|
|
// Do not forget to add Account information to the created video channel
|
|
|
|
videoChannelCreated.Account = account
|
2017-10-25 11:55:06 +02:00
|
|
|
|
2017-11-16 18:40:50 +01:00
|
|
|
// No need to seed this empty video channel to followers
|
2017-10-25 11:55:06 +02:00
|
|
|
return videoChannelCreated
|
|
|
|
}
|
|
|
|
|
2017-10-24 19:41:09 +02:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
2017-11-23 17:36:15 +01:00
|
|
|
createVideoChannel
|
2017-10-24 19:41:09 +02:00
|
|
|
}
|