]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/lib/video-channel.ts
Misc cleanup
[github/Chocobozzz/PeerTube.git] / server / lib / video-channel.ts
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'
6
7 async 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
31 export {
32 createVideoChannel
33 }