Federate video update
[oweals/peertube.git] / server / lib / video-channel.ts
index 13841ea33b7548348fc8c44e71db7feafbd13f66..e69ec062f2ad7bd442de775826570991f51f78d2 100644 (file)
@@ -5,7 +5,7 @@ import { logger } from '../helpers'
 import { AccountInstance } from '../models'
 import { VideoChannelCreate } from '../../shared/models'
 import { sendCreateVideoChannel } from './activitypub/send-request'
-import { getActivityPubUrl } from '../helpers/activitypub'
+import { getActivityPubUrl, shareVideoChannelByServer } from '../helpers/activitypub'
 
 async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountInstance, t: Sequelize.Transaction) {
   const videoChannelData = {
@@ -25,19 +25,20 @@ async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account
   // Do not forget to add Account information to the created video channel
   videoChannelCreated.Account = account
 
-  sendCreateVideoChannel(videoChannelCreated, t)
+  await sendCreateVideoChannel(videoChannelCreated, t)
+  await shareVideoChannelByServer(videoChannelCreated, t)
 
   return videoChannelCreated
 }
 
-async function fetchVideoChannelByHostAndUUID (podHost: string, uuid: string, t: Sequelize.Transaction) {
+async function fetchVideoChannelByHostAndUUID (serverHost: string, uuid: string, t: Sequelize.Transaction) {
   try {
-    const videoChannel = await db.VideoChannel.loadByHostAndUUID(podHost, uuid, t)
+    const videoChannel = await db.VideoChannel.loadByHostAndUUID(serverHost, uuid, t)
     if (!videoChannel) throw new Error('Video channel not found')
 
     return videoChannel
   } catch (err) {
-    logger.error('Cannot load video channel from host and uuid.', { error: err.stack, podHost, uuid })
+    logger.error('Cannot load video channel from host and uuid.', { error: err.stack, serverHost, uuid })
     throw err
   }
 }