diff options
Diffstat (limited to 'shared/utils/videos/video-channels.ts')
-rw-r--r-- | shared/utils/videos/video-channels.ts | 18 |
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 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' | 2 | import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' |
3 | import { updateAvatarRequest } from '../requests/requests' | 3 | import { updateAvatarRequest } from '../requests/requests' |
4 | import { getMyUserInformation, ServerInfo } from '..' | ||
5 | import { User } from '../..' | ||
4 | 6 | ||
5 | function getVideoChannelsList (url: string, start: number, count: number, sort?: string) { | 7 | function 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 | ||
110 | function 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 | ||
110 | export { | 125 | export { |
@@ -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 | } |