aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/utils/videos/video-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-03-05 10:58:44 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-03-18 11:17:59 +0100
commitdf0b219d36bf6852cdf2a7ad09ed4a41c6bccefa (patch)
treec4984e854f5dc18e5c27afd73b843bd52c143034 /shared/utils/videos/video-channels.ts
parent07b1a18aa678d260009a93e36606c5c5f585723d (diff)
downloadPeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.gz
PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.zst
PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.zip
Add playlist rest tests
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}