- return sendOwnedAuthorsToPod(podId)
- .then(() => sendOwnedChannelsToPod(podId))
- .then(() => sendOwnedVideosToPod(podId))
+ await sendOwnedAuthorsToPod(podId)
+ await sendOwnedChannelsToPod(podId)
+ await sendOwnedVideosToPod(podId)
+}
+
+async function sendOwnedChannelsToPod (podId: number) {
+ const videoChannels = await db.VideoChannel.listOwned()
+
+ const tasks: Promise<any>[] = []
+ for (const videoChannel of videoChannels) {
+ const remoteVideoChannel = videoChannel.toAddRemoteJSON()
+ const options = {
+ type: 'add-channel' as 'add-channel',
+ endpoint: REQUEST_ENDPOINTS.VIDEOS,
+ data: remoteVideoChannel,
+ toIds: [ podId ],
+ transaction: null
+ }
+
+ const p = createRequest(options)
+ tasks.push(p)
+ }
+
+ await Promise.all(tasks)