]>
Commit | Line | Data |
---|---|---|
72c7248b | 1 | import * as Sequelize from 'sequelize' |
79d5caf9 | 2 | import { VideoChannelCreate } from '../../shared/models' |
79d5caf9 | 3 | import { database as db } from '../initializers' |
e4f97bab | 4 | import { AccountInstance } from '../models' |
892211e8 | 5 | import { getVideoChannelActivityPubUrl } from './activitypub/url' |
72c7248b | 6 | |
e4f97bab | 7 | async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) { |
72c7248b C |
8 | const videoChannelData = { |
9 | name: videoChannelInfo.name, | |
10 | description: videoChannelInfo.description, | |
11 | remote: false, | |
38fa2065 | 12 | accountId: account.id |
72c7248b C |
13 | } |
14 | ||
15 | const videoChannel = db.VideoChannel.build(videoChannelData) | |
54141398 | 16 | videoChannel.set('url', getVideoChannelActivityPubUrl(videoChannel)) |
e34c85e5 | 17 | |
72c7248b C |
18 | const options = { transaction: t } |
19 | ||
eb080476 C |
20 | const videoChannelCreated = await videoChannel.save(options) |
21 | ||
e4f97bab C |
22 | // Do not forget to add Account information to the created video channel |
23 | videoChannelCreated.Account = account | |
eb080476 | 24 | |
47e0652b | 25 | // No need to seed this empty video channel to followers |
eb080476 C |
26 | return videoChannelCreated |
27 | } | |
28 | ||
72c7248b C |
29 | // --------------------------------------------------------------------------- |
30 | ||
31 | export { | |
39445ead | 32 | createVideoChannel |
72c7248b | 33 | } |