]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/lib/video-channel.ts
First step upload with new design
[github/Chocobozzz/PeerTube.git] / server / lib / video-channel.ts
... / ...
CommitLineData
1import * as Sequelize from 'sequelize'
2import { VideoChannelCreate } from '../../shared/models'
3import { database as db } from '../initializers'
4import { AccountInstance } from '../models'
5import { getVideoChannelActivityPubUrl } from './activitypub/url'
6
7async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
8 const videoChannelData = {
9 name: videoChannelInfo.name,
10 description: videoChannelInfo.description,
11 remote: false,
12 accountId: account.id
13 }
14
15 const videoChannel = db.VideoChannel.build(videoChannelData)
16 videoChannel.set('url', getVideoChannelActivityPubUrl(videoChannel))
17
18 const options = { transaction: t }
19
20 const videoChannelCreated = await videoChannel.save(options)
21
22 // Do not forget to add Account information to the created video channel
23 videoChannelCreated.Account = account
24
25 // No need to seed this empty video channel to followers
26 return videoChannelCreated
27}
28
29// ---------------------------------------------------------------------------
30
31export {
32 createVideoChannel
33}