aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/video-channel.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/video-channel.ts')
-rw-r--r--server/lib/video-channel.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/server/lib/video-channel.ts b/server/lib/video-channel.ts
index 97924aa9e..569b8f29d 100644
--- a/server/lib/video-channel.ts
+++ b/server/lib/video-channel.ts
@@ -1,26 +1,33 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import * as uuidv4 from 'uuid/v4'
2import { VideoChannelCreate } from '../../shared/models' 3import { VideoChannelCreate } from '../../shared/models'
3import { AccountModel } from '../models/account/account' 4import { AccountModel } from '../models/account/account'
4import { VideoChannelModel } from '../models/video/video-channel' 5import { VideoChannelModel } from '../models/video/video-channel'
5import { getVideoChannelActivityPubUrl } from './activitypub' 6import { buildActorInstance, getVideoChannelActivityPubUrl } from './activitypub'
6 7
7async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) { 8async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) {
9 const uuid = uuidv4()
10 const url = getVideoChannelActivityPubUrl(uuid)
11 // We use the name as uuid
12 const actorInstance = buildActorInstance('Group', url, uuid, uuid)
13
14 const actorInstanceCreated = await actorInstance.save({ transaction: t })
15
8 const videoChannelData = { 16 const videoChannelData = {
9 name: videoChannelInfo.name, 17 name: videoChannelInfo.name,
10 description: videoChannelInfo.description, 18 description: videoChannelInfo.description,
11 remote: false, 19 accountId: account.id,
12 accountId: account.id 20 actorId: actorInstanceCreated.id
13 } 21 }
14 22
15 const videoChannel = VideoChannelModel.build(videoChannelData) 23 const videoChannel = VideoChannelModel.build(videoChannelData)
16 videoChannel.set('url', getVideoChannelActivityPubUrl(videoChannel))
17 24
18 const options = { transaction: t } 25 const options = { transaction: t }
19
20 const videoChannelCreated = await videoChannel.save(options) 26 const videoChannelCreated = await videoChannel.save(options)
21 27
22 // Do not forget to add Account information to the created video channel 28 // Do not forget to add Account/Actor information to the created video channel
23 videoChannelCreated.Account = account 29 videoChannelCreated.Account = account
30 videoChannelCreated.Actor = actorInstanceCreated
24 31
25 // No need to seed this empty video channel to followers 32 // No need to seed this empty video channel to followers
26 return videoChannelCreated 33 return videoChannelCreated