aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/videos/video-channels.ts
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/videos/video-channels.ts')
-rw-r--r--shared/extra-utils/videos/video-channels.ts24
1 files changed, 17 insertions, 7 deletions
diff --git a/shared/extra-utils/videos/video-channels.ts b/shared/extra-utils/videos/video-channels.ts
index 97b68178f..3ff445c2a 100644
--- a/shared/extra-utils/videos/video-channels.ts
+++ b/shared/extra-utils/videos/video-channels.ts
@@ -7,6 +7,7 @@ import { makeGetRequest, updateAvatarRequest } from '../requests/requests'
7import { ServerInfo } from '../server/servers' 7import { ServerInfo } from '../server/servers'
8import { User } from '../../models/users/user.model' 8import { User } from '../../models/users/user.model'
9import { getMyUserInformation } from '../users/users' 9import { getMyUserInformation } from '../users/users'
10import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
10 11
11function getVideoChannelsList (url: string, start: number, count: number, sort?: string, withStats?: boolean) { 12function getVideoChannelsList (url: string, start: number, count: number, sort?: string, withStats?: boolean) {
12 const path = '/api/v1/video-channels' 13 const path = '/api/v1/video-channels'
@@ -20,7 +21,7 @@ function getVideoChannelsList (url: string, start: number, count: number, sort?:
20 if (withStats) req.query({ withStats }) 21 if (withStats) req.query({ withStats })
21 22
22 return req.set('Accept', 'application/json') 23 return req.set('Accept', 'application/json')
23 .expect(200) 24 .expect(HttpStatusCode.OK_200)
24 .expect('Content-Type', /json/) 25 .expect('Content-Type', /json/)
25} 26}
26 27
@@ -30,11 +31,20 @@ function getAccountVideoChannelsList (parameters: {
30 start?: number 31 start?: number
31 count?: number 32 count?: number
32 sort?: string 33 sort?: string
33 specialStatus?: number 34 specialStatus?: HttpStatusCode
34 withStats?: boolean 35 withStats?: boolean
35 search?: string 36 search?: string
36}) { 37}) {
37 const { url, accountName, start, count, sort = 'createdAt', specialStatus = 200, withStats = false, search } = parameters 38 const {
39 url,
40 accountName,
41 start,
42 count,
43 sort = 'createdAt',
44 specialStatus = HttpStatusCode.OK_200,
45 withStats = false,
46 search
47 } = parameters
38 48
39 const path = '/api/v1/accounts/' + accountName + '/video-channels' 49 const path = '/api/v1/accounts/' + accountName + '/video-channels'
40 50
@@ -56,7 +66,7 @@ function addVideoChannel (
56 url: string, 66 url: string,
57 token: string, 67 token: string,
58 videoChannelAttributesArg: VideoChannelCreate, 68 videoChannelAttributesArg: VideoChannelCreate,
59 expectedStatus = 200 69 expectedStatus = HttpStatusCode.OK_200
60) { 70) {
61 const path = '/api/v1/video-channels/' 71 const path = '/api/v1/video-channels/'
62 72
@@ -81,7 +91,7 @@ function updateVideoChannel (
81 token: string, 91 token: string,
82 channelName: string, 92 channelName: string,
83 attributes: VideoChannelUpdate, 93 attributes: VideoChannelUpdate,
84 expectedStatus = 204 94 expectedStatus = HttpStatusCode.NO_CONTENT_204
85) { 95) {
86 const body: any = {} 96 const body: any = {}
87 const path = '/api/v1/video-channels/' + channelName 97 const path = '/api/v1/video-channels/' + channelName
@@ -99,7 +109,7 @@ function updateVideoChannel (
99 .expect(expectedStatus) 109 .expect(expectedStatus)
100} 110}
101 111
102function deleteVideoChannel (url: string, token: string, channelName: string, expectedStatus = 204) { 112function deleteVideoChannel (url: string, token: string, channelName: string, expectedStatus = HttpStatusCode.NO_CONTENT_204) {
103 const path = '/api/v1/video-channels/' + channelName 113 const path = '/api/v1/video-channels/' + channelName
104 114
105 return request(url) 115 return request(url)
@@ -115,7 +125,7 @@ function getVideoChannel (url: string, channelName: string) {
115 return request(url) 125 return request(url)
116 .get(path) 126 .get(path)
117 .set('Accept', 'application/json') 127 .set('Accept', 'application/json')
118 .expect(200) 128 .expect(HttpStatusCode.OK_200)
119 .expect('Content-Type', /json/) 129 .expect('Content-Type', /json/)
120} 130}
121 131