]>
Commit | Line | Data |
---|---|---|
72c7248b | 1 | import * as Sequelize from 'sequelize' |
50d6de9c | 2 | import * as uuidv4 from 'uuid/v4' |
79d5caf9 | 3 | import { VideoChannelCreate } from '../../shared/models' |
3fd3ab2d C |
4 | import { AccountModel } from '../models/account/account' |
5 | import { VideoChannelModel } from '../models/video/video-channel' | |
50d6de9c | 6 | import { buildActorInstance, getVideoChannelActivityPubUrl } from './activitypub' |
72c7248b | 7 | |
3fd3ab2d | 8 | async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) { |
50d6de9c | 9 | const uuid = uuidv4() |
8a19bee1 C |
10 | const url = getVideoChannelActivityPubUrl(videoChannelInfo.name) |
11 | const actorInstance = buildActorInstance('Group', url, videoChannelInfo.name, uuid) | |
50d6de9c C |
12 | |
13 | const actorInstanceCreated = await actorInstance.save({ transaction: t }) | |
14 | ||
72c7248b | 15 | const videoChannelData = { |
08c1efbe | 16 | name: videoChannelInfo.displayName, |
72c7248b | 17 | description: videoChannelInfo.description, |
2422c46b | 18 | support: videoChannelInfo.support, |
50d6de9c C |
19 | accountId: account.id, |
20 | actorId: actorInstanceCreated.id | |
72c7248b C |
21 | } |
22 | ||
3fd3ab2d | 23 | const videoChannel = VideoChannelModel.build(videoChannelData) |
e34c85e5 | 24 | |
72c7248b | 25 | const options = { transaction: t } |
eb080476 C |
26 | const videoChannelCreated = await videoChannel.save(options) |
27 | ||
50d6de9c | 28 | // Do not forget to add Account/Actor information to the created video channel |
e4f97bab | 29 | videoChannelCreated.Account = account |
50d6de9c | 30 | videoChannelCreated.Actor = actorInstanceCreated |
eb080476 | 31 | |
47e0652b | 32 | // No need to seed this empty video channel to followers |
eb080476 C |
33 | return videoChannelCreated |
34 | } | |
35 | ||
72c7248b C |
36 | // --------------------------------------------------------------------------- |
37 | ||
38 | export { | |
39445ead | 39 | createVideoChannel |
72c7248b | 40 | } |