diff options
Diffstat (limited to 'server/lib/video-channel.ts')
-rw-r--r-- | server/lib/video-channel.ts | 19 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import * as uuidv4 from 'uuid/v4' | ||
2 | import { VideoChannelCreate } from '../../shared/models' | 3 | import { VideoChannelCreate } from '../../shared/models' |
3 | import { AccountModel } from '../models/account/account' | 4 | import { AccountModel } from '../models/account/account' |
4 | import { VideoChannelModel } from '../models/video/video-channel' | 5 | import { VideoChannelModel } from '../models/video/video-channel' |
5 | import { getVideoChannelActivityPubUrl } from './activitypub' | 6 | import { buildActorInstance, getVideoChannelActivityPubUrl } from './activitypub' |
6 | 7 | ||
7 | async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) { | 8 | async 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 |