diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-14 17:38:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch) | |
tree | f1732b27edcd05c7877a8358b8312f1e38c287ed /server/lib/video-channel.ts | |
parent | fadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff) | |
download | PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip |
Begin moving video channel to actor
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 |