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