aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/utils/videos/video-channels.ts')
-rw-r--r--shared/utils/videos/video-channels.ts18
1 files changed, 17 insertions, 1 deletions
diff --git a/shared/utils/videos/video-channels.ts b/shared/utils/videos/video-channels.ts
index 3935c261e..93a257bf9 100644
--- a/shared/utils/videos/video-channels.ts
+++ b/shared/utils/videos/video-channels.ts
@@ -1,6 +1,8 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' 2import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos'
3import { updateAvatarRequest } from '../requests/requests' 3import { updateAvatarRequest } from '../requests/requests'
4import { getMyUserInformation, ServerInfo } from '..'
5import { User } from '../..'
4 6
5function getVideoChannelsList (url: string, start: number, count: number, sort?: string) { 7function getVideoChannelsList (url: string, start: number, count: number, sort?: string) {
6 const path = '/api/v1/video-channels' 8 const path = '/api/v1/video-channels'
@@ -105,6 +107,19 @@ function updateVideoChannelAvatar (options: {
105 return updateAvatarRequest(Object.assign(options, { path })) 107 return updateAvatarRequest(Object.assign(options, { path }))
106} 108}
107 109
110function setDefaultVideoChannel (servers: ServerInfo[]) {
111 const tasks: Promise<any>[] = []
112
113 for (const server of servers) {
114 const p = getMyUserInformation(server.url, server.accessToken)
115 .then(res => server.videoChannel = (res.body as User).videoChannels[0])
116
117 tasks.push(p)
118 }
119
120 return Promise.all(tasks)
121}
122
108// --------------------------------------------------------------------------- 123// ---------------------------------------------------------------------------
109 124
110export { 125export {
@@ -114,5 +129,6 @@ export {
114 addVideoChannel, 129 addVideoChannel,
115 updateVideoChannel, 130 updateVideoChannel,
116 deleteVideoChannel, 131 deleteVideoChannel,
117 getVideoChannel 132 getVideoChannel,
133 setDefaultVideoChannel
118} 134}