diff options
Diffstat (limited to 'shared')
50 files changed, 204 insertions, 283 deletions
diff --git a/shared/core-utils/miscs/index.ts b/shared/core-utils/miscs/index.ts index 251df1de2..afd147f24 100644 --- a/shared/core-utils/miscs/index.ts +++ b/shared/core-utils/miscs/index.ts | |||
@@ -1,5 +1,3 @@ | |||
1 | export * from './date' | 1 | export * from './date' |
2 | export * from './miscs' | 2 | export * from './miscs' |
3 | export * from './types' | 3 | export * from './types' |
4 | export * from './http-error-codes' | ||
5 | export * from './http-methods' | ||
diff --git a/shared/extra-utils/bulk/bulk-command.ts b/shared/extra-utils/bulk/bulk-command.ts index 6dac6034f..b5c5673ce 100644 --- a/shared/extra-utils/bulk/bulk-command.ts +++ b/shared/extra-utils/bulk/bulk-command.ts | |||
@@ -1,6 +1,4 @@ | |||
1 | 1 | import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@shared/models' | |
2 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' | ||
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 3 | ||
6 | export class BulkCommand extends AbstractCommand { | 4 | export class BulkCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/custom-pages/custom-pages-command.ts b/shared/extra-utils/custom-pages/custom-pages-command.ts index 0dd77503e..6042233d4 100644 --- a/shared/extra-utils/custom-pages/custom-pages-command.ts +++ b/shared/extra-utils/custom-pages/custom-pages-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { CustomPage } from '@shared/models' | 1 | import { CustomPage } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class CustomPagesCommand extends AbstractCommand { | 5 | export class CustomPagesCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts index 2da4110a7..3c95f9536 100644 --- a/shared/extra-utils/feeds/feeds-command.ts +++ b/shared/extra-utils/feeds/feeds-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' | 5 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' |
diff --git a/shared/extra-utils/logs/logs-command.ts b/shared/extra-utils/logs/logs-command.ts index f34c58c47..5912e814f 100644 --- a/shared/extra-utils/logs/logs-command.ts +++ b/shared/extra-utils/logs/logs-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { LogLevel } from '../../models/server/log-level.type' | 2 | import { LogLevel } from '../../models/server/log-level.type' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts index c81460330..7fc92f804 100644 --- a/shared/extra-utils/miscs/checks.ts +++ b/shared/extra-utils/miscs/checks.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import { pathExists, readFile } from 'fs-extra' | 4 | import { pathExists, readFile } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@server/helpers/core-utils' | 6 | import { root } from '@server/helpers/core-utils' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { makeGetRequest } from '../requests' | 8 | import { makeGetRequest } from '../requests' |
9 | import { PeerTubeServer } from '../server' | 9 | import { PeerTubeServer } from '../server' |
10 | 10 | ||
@@ -20,7 +20,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext | |||
20 | const res = await makeGetRequest({ | 20 | const res = await makeGetRequest({ |
21 | url, | 21 | url, |
22 | path: imagePath, | 22 | path: imagePath, |
23 | statusCodeExpected: HttpStatusCode.OK_200 | 23 | expectedStatus: HttpStatusCode.OK_200 |
24 | }) | 24 | }) |
25 | 25 | ||
26 | const body = res.body | 26 | const body = res.body |
diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts index 03da0c85a..72f2c9951 100644 --- a/shared/extra-utils/moderation/abuses-command.ts +++ b/shared/extra-utils/moderation/abuses-command.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | ResultList, | 10 | ResultList, |
11 | UserAbuse | 11 | UserAbuse |
12 | } from '@shared/models' | 12 | } from '@shared/models' |
13 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '@shared/models' |
14 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 14 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
15 | import { unwrapBody } from '../requests/requests' | 15 | import { unwrapBody } from '../requests/requests' |
16 | 16 | ||
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts index e15644d94..d4a2ac254 100644 --- a/shared/extra-utils/overviews/overviews-command.ts +++ b/shared/extra-utils/overviews/overviews-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { VideosOverview } from '@shared/models' | 2 | import { VideosOverview } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/requests/check-api-params.ts b/shared/extra-utils/requests/check-api-params.ts index 7df63b004..26ba1e913 100644 --- a/shared/extra-utils/requests/check-api-params.ts +++ b/shared/extra-utils/requests/check-api-params.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { makeGetRequest } from './requests' | 2 | import { makeGetRequest } from './requests' |
3 | 3 | ||
4 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { | 4 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { |
@@ -7,7 +7,7 @@ function checkBadStartPagination (url: string, path: string, token?: string, que | |||
7 | path, | 7 | path, |
8 | token, | 8 | token, |
9 | query: { ...query, start: 'hello' }, | 9 | query: { ...query, start: 'hello' }, |
10 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 10 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
11 | }) | 11 | }) |
12 | } | 12 | } |
13 | 13 | ||
@@ -17,7 +17,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin | |||
17 | path, | 17 | path, |
18 | token, | 18 | token, |
19 | query: { ...query, count: 'hello' }, | 19 | query: { ...query, count: 'hello' }, |
20 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 20 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
21 | }) | 21 | }) |
22 | 22 | ||
23 | await makeGetRequest({ | 23 | await makeGetRequest({ |
@@ -25,7 +25,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin | |||
25 | path, | 25 | path, |
26 | token, | 26 | token, |
27 | query: { ...query, count: 2000 }, | 27 | query: { ...query, count: 2000 }, |
28 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 28 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
29 | }) | 29 | }) |
30 | } | 30 | } |
31 | 31 | ||
@@ -35,7 +35,7 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer | |||
35 | path, | 35 | path, |
36 | token, | 36 | token, |
37 | query: { ...query, sort: 'hello' }, | 37 | query: { ...query, sort: 'hello' }, |
38 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 38 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
39 | }) | 39 | }) |
40 | } | 40 | } |
41 | 41 | ||
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts index 60c9b938b..70f790222 100644 --- a/shared/extra-utils/requests/requests.ts +++ b/shared/extra-utils/requests/requests.ts | |||
@@ -1,111 +1,82 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ | 1 | /* eslint-disable @typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { isAbsolute, join } from 'path' | ||
4 | import { decode } from 'querystring' | 3 | import { decode } from 'querystring' |
5 | import * as request from 'supertest' | 4 | import * as request from 'supertest' |
6 | import { URL } from 'url' | 5 | import { URL } from 'url' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
8 | import { buildAbsoluteFixturePath, root } from '../miscs/tests' | 7 | import { buildAbsoluteFixturePath } from '../miscs/tests' |
9 | 8 | ||
10 | function makeRawRequest (url: string, statusCodeExpected?: HttpStatusCode, range?: string) { | 9 | export type CommonRequestParams = { |
11 | const { host, protocol, pathname } = new URL(url) | ||
12 | |||
13 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range }) | ||
14 | } | ||
15 | |||
16 | function makeGetRequest (options: { | ||
17 | url: string | 10 | url: string |
18 | path?: string | 11 | path?: string |
19 | query?: any | ||
20 | token?: string | ||
21 | statusCodeExpected?: HttpStatusCode | ||
22 | contentType?: string | 12 | contentType?: string |
23 | range?: string | 13 | range?: string |
24 | redirects?: number | 14 | redirects?: number |
25 | accept?: string | 15 | accept?: string |
26 | host?: string | 16 | host?: string |
27 | }) { | 17 | token?: string |
28 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 18 | headers?: { [ name: string ]: string } |
29 | if (options.contentType === undefined) options.contentType = 'application/json' | 19 | type?: string |
30 | 20 | xForwardedFor?: string | |
31 | const req = request(options.url).get(options.path) | 21 | expectedStatus?: HttpStatusCode |
22 | } | ||
32 | 23 | ||
33 | if (options.contentType) req.set('Accept', options.contentType) | 24 | function makeRawRequest (url: string, expectedStatus?: HttpStatusCode, range?: string) { |
34 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 25 | const { host, protocol, pathname } = new URL(url) |
35 | if (options.query) req.query(options.query) | ||
36 | if (options.range) req.set('Range', options.range) | ||
37 | if (options.accept) req.set('Accept', options.accept) | ||
38 | if (options.host) req.set('Host', options.host) | ||
39 | if (options.redirects) req.redirects(options.redirects) | ||
40 | 26 | ||
41 | return req.expect(options.statusCodeExpected) | 27 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, expectedStatus, range }) |
42 | } | 28 | } |
43 | 29 | ||
44 | function makeDeleteRequest (options: { | 30 | function makeGetRequest (options: CommonRequestParams & { |
45 | url: string | 31 | query?: any |
46 | path: string | ||
47 | token?: string | ||
48 | statusCodeExpected?: HttpStatusCode | ||
49 | }) { | 32 | }) { |
50 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 33 | const req = request(options.url).get(options.path) |
34 | .query(options.query) | ||
51 | 35 | ||
52 | const req = request(options.url) | 36 | return buildRequest(req, { contentType: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
53 | .delete(options.path) | 37 | } |
54 | .set('Accept', 'application/json') | ||
55 | 38 | ||
56 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 39 | function makeHTMLRequest (url: string, path: string) { |
40 | return makeGetRequest({ | ||
41 | url, | ||
42 | path, | ||
43 | accept: 'text/html', | ||
44 | expectedStatus: HttpStatusCode.OK_200 | ||
45 | }) | ||
46 | } | ||
57 | 47 | ||
58 | return req.expect(options.statusCodeExpected) | 48 | function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { |
49 | return makeGetRequest({ | ||
50 | url, | ||
51 | path, | ||
52 | expectedStatus: expectedStatus, | ||
53 | accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' | ||
54 | }) | ||
59 | } | 55 | } |
60 | 56 | ||
61 | function makeUploadRequest (options: { | 57 | function makeDeleteRequest (options: CommonRequestParams) { |
62 | url: string | 58 | const req = request(options.url).delete(options.path) |
59 | |||
60 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) | ||
61 | } | ||
62 | |||
63 | function makeUploadRequest (options: CommonRequestParams & { | ||
63 | method?: 'POST' | 'PUT' | 64 | method?: 'POST' | 'PUT' |
64 | path: string | ||
65 | token?: string | ||
66 | 65 | ||
67 | fields: { [ fieldName: string ]: any } | 66 | fields: { [ fieldName: string ]: any } |
68 | attaches?: { [ attachName: string ]: any | any[] } | 67 | attaches?: { [ attachName: string ]: any | any[] } |
69 | |||
70 | headers?: { [ name: string ]: string } | ||
71 | |||
72 | statusCodeExpected?: HttpStatusCode | ||
73 | }) { | 68 | }) { |
74 | if (options.statusCodeExpected === undefined) { | 69 | let req = options.method === 'PUT' |
75 | options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 70 | ? request(options.url).put(options.path) |
76 | } | 71 | : request(options.url).post(options.path) |
77 | 72 | ||
78 | let req: request.Test | 73 | req = buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
79 | if (options.method === 'PUT') { | ||
80 | req = request(options.url).put(options.path) | ||
81 | } else { | ||
82 | req = request(options.url).post(options.path) | ||
83 | } | ||
84 | 74 | ||
85 | req.set('Accept', 'application/json') | 75 | buildFields(req, options.fields) |
86 | |||
87 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
88 | |||
89 | Object.keys(options.headers || {}).forEach(name => { | ||
90 | req.set(name, options.headers[name]) | ||
91 | }) | ||
92 | |||
93 | Object.keys(options.fields).forEach(field => { | ||
94 | const value = options.fields[field] | ||
95 | |||
96 | if (value === undefined) return | ||
97 | |||
98 | if (Array.isArray(value)) { | ||
99 | for (let i = 0; i < value.length; i++) { | ||
100 | req.field(field + '[' + i + ']', value[i]) | ||
101 | } | ||
102 | } else { | ||
103 | req.field(field, value) | ||
104 | } | ||
105 | }) | ||
106 | 76 | ||
107 | Object.keys(options.attaches || {}).forEach(attach => { | 77 | Object.keys(options.attaches || {}).forEach(attach => { |
108 | const value = options.attaches[attach] | 78 | const value = options.attaches[attach] |
79 | |||
109 | if (Array.isArray(value)) { | 80 | if (Array.isArray(value)) { |
110 | req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1]) | 81 | req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1]) |
111 | } else { | 82 | } else { |
@@ -113,40 +84,16 @@ function makeUploadRequest (options: { | |||
113 | } | 84 | } |
114 | }) | 85 | }) |
115 | 86 | ||
116 | if (options.statusCodeExpected) { | ||
117 | req.expect(options.statusCodeExpected) | ||
118 | } | ||
119 | |||
120 | return req | 87 | return req |
121 | } | 88 | } |
122 | 89 | ||
123 | function makePostBodyRequest (options: { | 90 | function makePostBodyRequest (options: CommonRequestParams & { |
124 | url: string | ||
125 | path: string | ||
126 | token?: string | ||
127 | fields?: { [ fieldName: string ]: any } | 91 | fields?: { [ fieldName: string ]: any } |
128 | headers?: { [ name: string ]: string } | ||
129 | type?: string | ||
130 | xForwardedFor?: string | ||
131 | statusCodeExpected?: HttpStatusCode | ||
132 | }) { | 92 | }) { |
133 | if (!options.fields) options.fields = {} | 93 | const req = request(options.url).post(options.path) |
134 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 94 | .send(options.fields) |
135 | |||
136 | const req = request(options.url) | ||
137 | .post(options.path) | ||
138 | .set('Accept', 'application/json') | ||
139 | 95 | ||
140 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 96 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
141 | if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor) | ||
142 | if (options.type) req.type(options.type) | ||
143 | |||
144 | Object.keys(options.headers || {}).forEach(name => { | ||
145 | req.set(name, options.headers[name]) | ||
146 | }) | ||
147 | |||
148 | return req.send(options.fields) | ||
149 | .expect(options.statusCodeExpected) | ||
150 | } | 97 | } |
151 | 98 | ||
152 | function makePutBodyRequest (options: { | 99 | function makePutBodyRequest (options: { |
@@ -154,58 +101,12 @@ function makePutBodyRequest (options: { | |||
154 | path: string | 101 | path: string |
155 | token?: string | 102 | token?: string |
156 | fields: { [ fieldName: string ]: any } | 103 | fields: { [ fieldName: string ]: any } |
157 | statusCodeExpected?: HttpStatusCode | 104 | expectedStatus?: HttpStatusCode |
158 | }) { | ||
159 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | ||
160 | |||
161 | const req = request(options.url) | ||
162 | .put(options.path) | ||
163 | .set('Accept', 'application/json') | ||
164 | |||
165 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
166 | |||
167 | return req.send(options.fields) | ||
168 | .expect(options.statusCodeExpected) | ||
169 | } | ||
170 | |||
171 | function makeHTMLRequest (url: string, path: string) { | ||
172 | return request(url) | ||
173 | .get(path) | ||
174 | .set('Accept', 'text/html') | ||
175 | .expect(HttpStatusCode.OK_200) | ||
176 | } | ||
177 | |||
178 | function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { | ||
179 | return makeGetRequest({ | ||
180 | url, | ||
181 | path, | ||
182 | statusCodeExpected: expectedStatus, | ||
183 | accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' | ||
184 | }) | ||
185 | } | ||
186 | |||
187 | function updateImageRequest (options: { | ||
188 | url: string | ||
189 | path: string | ||
190 | accessToken: string | ||
191 | fixture: string | ||
192 | fieldname: string | ||
193 | }) { | 105 | }) { |
194 | let filePath = '' | 106 | const req = request(options.url).put(options.path) |
195 | if (isAbsolute(options.fixture)) { | 107 | .send(options.fields) |
196 | filePath = options.fixture | ||
197 | } else { | ||
198 | filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture) | ||
199 | } | ||
200 | 108 | ||
201 | return makeUploadRequest({ | 109 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
202 | url: options.url, | ||
203 | path: options.path, | ||
204 | token: options.accessToken, | ||
205 | fields: {}, | ||
206 | attaches: { [options.fieldname]: filePath }, | ||
207 | statusCodeExpected: HttpStatusCode.OK_200 | ||
208 | }) | ||
209 | } | 110 | } |
210 | 111 | ||
211 | function decodeQueryString (path: string) { | 112 | function decodeQueryString (path: string) { |
@@ -233,6 +134,49 @@ export { | |||
233 | makeRawRequest, | 134 | makeRawRequest, |
234 | makeActivityPubGetRequest, | 135 | makeActivityPubGetRequest, |
235 | unwrapBody, | 136 | unwrapBody, |
236 | unwrapText, | 137 | unwrapText |
237 | updateImageRequest | 138 | } |
139 | |||
140 | // --------------------------------------------------------------------------- | ||
141 | |||
142 | function buildRequest (req: request.Test, options: CommonRequestParams) { | ||
143 | if (options.contentType) req.set('Accept', options.contentType) | ||
144 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
145 | if (options.range) req.set('Range', options.range) | ||
146 | if (options.accept) req.set('Accept', options.accept) | ||
147 | if (options.host) req.set('Host', options.host) | ||
148 | if (options.redirects) req.redirects(options.redirects) | ||
149 | if (options.expectedStatus) req.expect(options.expectedStatus) | ||
150 | if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor) | ||
151 | if (options.type) req.type(options.type) | ||
152 | |||
153 | Object.keys(options.headers || {}).forEach(name => { | ||
154 | req.set(name, options.headers[name]) | ||
155 | }) | ||
156 | |||
157 | return req | ||
158 | } | ||
159 | |||
160 | function buildFields (req: request.Test, fields: { [ fieldName: string ]: any }, namespace?: string) { | ||
161 | if (!fields) return | ||
162 | |||
163 | let formKey: string | ||
164 | |||
165 | for (const key of Object.keys(fields)) { | ||
166 | if (namespace) formKey = `${namespace}[${key}]` | ||
167 | else formKey = key | ||
168 | |||
169 | if (fields[key] === undefined) continue | ||
170 | |||
171 | if (Array.isArray(fields[key]) && fields[key].length === 0) { | ||
172 | req.field(key, null) | ||
173 | continue | ||
174 | } | ||
175 | |||
176 | if (fields[key] !== null && typeof fields[key] === 'object') { | ||
177 | buildFields(req, fields[key], formKey) | ||
178 | } else { | ||
179 | req.field(formKey, fields[key]) | ||
180 | } | ||
181 | } | ||
238 | } | 182 | } |
diff --git a/shared/extra-utils/search/search-command.ts b/shared/extra-utils/search/search-command.ts index 7539a21ec..09f5d3f1d 100644 --- a/shared/extra-utils/search/search-command.ts +++ b/shared/extra-utils/search/search-command.ts | |||
@@ -7,7 +7,7 @@ import { | |||
7 | VideoPlaylistsSearchQuery, | 7 | VideoPlaylistsSearchQuery, |
8 | VideosSearchQuery | 8 | VideosSearchQuery |
9 | } from '@shared/models' | 9 | } from '@shared/models' |
10 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 10 | import { HttpStatusCode } from '@shared/models' |
11 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 11 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
12 | 12 | ||
13 | export class SearchCommand extends AbstractCommand { | 13 | export class SearchCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts index f5d7fc5e3..6e875fdf6 100644 --- a/shared/extra-utils/server/config-command.ts +++ b/shared/extra-utils/server/config-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { merge } from 'lodash' | 1 | import { merge } from 'lodash' |
2 | import { DeepPartial, HttpStatusCode } from '@shared/core-utils' | 2 | import { DeepPartial } from '@shared/core-utils' |
3 | import { About, ServerConfig } from '@shared/models' | 3 | import { About, ServerConfig, HttpStatusCode } from '@shared/models' |
4 | import { CustomConfig } from '../../models/server/custom-config.model' | 4 | import { CustomConfig } from '../../models/server/custom-config.model' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/server/contact-form-command.ts b/shared/extra-utils/server/contact-form-command.ts index 8d034552b..0e8fd6d84 100644 --- a/shared/extra-utils/server/contact-form-command.ts +++ b/shared/extra-utils/server/contact-form-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { ContactForm } from '../../models/server' | 2 | import { ContactForm } from '../../models/server' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts index 8b24b3067..36704836d 100644 --- a/shared/extra-utils/server/debug-command.ts +++ b/shared/extra-utils/server/debug-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Debug, SendDebugCommand } from '@shared/models' | 1 | import { Debug, SendDebugCommand } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class DebugCommand extends AbstractCommand { | 5 | export class DebugCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts index 4e9ed9494..694f5ea24 100644 --- a/shared/extra-utils/server/follows-command.ts +++ b/shared/extra-utils/server/follows-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models' | 2 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts index 392b868c1..09a299e5b 100644 --- a/shared/extra-utils/server/jobs-command.ts +++ b/shared/extra-utils/server/jobs-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Job, JobState, JobType, ResultList } from '../../models' | 3 | import { Job, JobState, JobType, ResultList } from '../../models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts index 98049ce19..59bc79b3d 100644 --- a/shared/extra-utils/server/plugins-command.ts +++ b/shared/extra-utils/server/plugins-command.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { readJSON, writeJSON } from 'fs-extra' | 3 | import { readJSON, writeJSON } from 'fs-extra' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { root } from '@server/helpers/core-utils' | 5 | import { root } from '@server/helpers/core-utils' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | PeerTubePlugin, | 8 | PeerTubePlugin, |
9 | PeerTubePluginIndex, | 9 | PeerTubePluginIndex, |
diff --git a/shared/extra-utils/server/redundancy-command.ts b/shared/extra-utils/server/redundancy-command.ts index 728332fdd..137d7f01c 100644 --- a/shared/extra-utils/server/redundancy-command.ts +++ b/shared/extra-utils/server/redundancy-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' | 1 | import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class RedundancyCommand extends AbstractCommand { | 5 | export class RedundancyCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts index cc6df2efe..b33bb9d1e 100644 --- a/shared/extra-utils/server/server.ts +++ b/shared/extra-utils/server/server.ts | |||
@@ -254,7 +254,7 @@ export class PeerTubeServer { | |||
254 | 254 | ||
255 | process.on('exit', () => { | 255 | process.on('exit', () => { |
256 | try { | 256 | try { |
257 | process.kill(self.server.app.pid) | 257 | process.kill(self.app.pid) |
258 | } catch { /* empty */ } | 258 | } catch { /* empty */ } |
259 | }) | 259 | }) |
260 | 260 | ||
diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts index 1a7b2aade..107e2b4ad 100644 --- a/shared/extra-utils/server/servers-command.ts +++ b/shared/extra-utils/server/servers-command.ts | |||
@@ -2,7 +2,7 @@ import { exec } from 'child_process' | |||
2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' | 2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root } from '@server/helpers/core-utils' | 4 | import { root } from '@server/helpers/core-utils' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { getFileSize } from '@uploadx/core' | 6 | import { getFileSize } from '@uploadx/core' |
7 | import { isGithubCI, wait } from '../miscs' | 7 | import { isGithubCI, wait } from '../miscs' |
8 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 8 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts index f0f02ca08..6db473588 100644 --- a/shared/extra-utils/server/stats-command.ts +++ b/shared/extra-utils/server/stats-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ServerStats } from '@shared/models' | 1 | import { ServerStats } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class StatsCommand extends AbstractCommand { | 5 | export class StatsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts index 967f8f2ac..021045e49 100644 --- a/shared/extra-utils/shared/abstract-command.ts +++ b/shared/extra-utils/shared/abstract-command.ts | |||
@@ -24,15 +24,20 @@ interface InternalCommonCommandOptions extends OverrideCommandOptions { | |||
24 | // If we automatically send the server token if the token is not provided | 24 | // If we automatically send the server token if the token is not provided |
25 | implicitToken: boolean | 25 | implicitToken: boolean |
26 | defaultExpectedStatus: number | 26 | defaultExpectedStatus: number |
27 | } | ||
28 | 27 | ||
29 | interface InternalGetCommandOptions extends InternalCommonCommandOptions { | 28 | // Common optional request parameters |
30 | query?: { [ id: string ]: any } | ||
31 | contentType?: string | 29 | contentType?: string |
32 | accept?: string | 30 | accept?: string |
33 | redirects?: number | 31 | redirects?: number |
34 | range?: string | 32 | range?: string |
35 | host?: string | 33 | host?: string |
34 | headers?: { [ name: string ]: string } | ||
35 | requestType?: string | ||
36 | xForwardedFor?: string | ||
37 | } | ||
38 | |||
39 | interface InternalGetCommandOptions extends InternalCommonCommandOptions { | ||
40 | query?: { [ id: string ]: any } | ||
36 | } | 41 | } |
37 | 42 | ||
38 | abstract class AbstractCommand { | 43 | abstract class AbstractCommand { |
@@ -59,7 +64,7 @@ abstract class AbstractCommand { | |||
59 | ...options, | 64 | ...options, |
60 | 65 | ||
61 | token: this.buildCommonRequestToken(options), | 66 | token: this.buildCommonRequestToken(options), |
62 | defaultExpectedStatus: this.buildStatusCodeExpected(options), | 67 | defaultExpectedStatus: this.buildExpectedStatus(options), |
63 | 68 | ||
64 | url: `${protocol}//${host}`, | 69 | url: `${protocol}//${host}`, |
65 | path: pathname, | 70 | path: pathname, |
@@ -68,17 +73,12 @@ abstract class AbstractCommand { | |||
68 | } | 73 | } |
69 | 74 | ||
70 | protected getRequest (options: InternalGetCommandOptions) { | 75 | protected getRequest (options: InternalGetCommandOptions) { |
71 | const { redirects, query, contentType, accept, range, host } = options | 76 | const { query } = options |
72 | 77 | ||
73 | return makeGetRequest({ | 78 | return makeGetRequest({ |
74 | ...this.buildCommonRequestOptions(options), | 79 | ...this.buildCommonRequestOptions(options), |
75 | 80 | ||
76 | redirects, | 81 | query |
77 | query, | ||
78 | contentType, | ||
79 | range, | ||
80 | host, | ||
81 | accept | ||
82 | }) | 82 | }) |
83 | } | 83 | } |
84 | 84 | ||
@@ -100,51 +100,41 @@ abstract class AbstractCommand { | |||
100 | 100 | ||
101 | protected postBodyRequest (options: InternalCommonCommandOptions & { | 101 | protected postBodyRequest (options: InternalCommonCommandOptions & { |
102 | fields?: { [ fieldName: string ]: any } | 102 | fields?: { [ fieldName: string ]: any } |
103 | headers?: { [ name: string ]: string } | ||
104 | type?: string | ||
105 | xForwardedFor?: string | ||
106 | }) { | 103 | }) { |
107 | const { type, fields, xForwardedFor, headers } = options | 104 | const { fields } = options |
108 | 105 | ||
109 | return makePostBodyRequest({ | 106 | return makePostBodyRequest({ |
110 | ...this.buildCommonRequestOptions(options), | 107 | ...this.buildCommonRequestOptions(options), |
111 | 108 | ||
112 | fields, | 109 | fields |
113 | xForwardedFor, | ||
114 | type, | ||
115 | headers | ||
116 | }) | 110 | }) |
117 | } | 111 | } |
118 | 112 | ||
119 | protected postUploadRequest (options: InternalCommonCommandOptions & { | 113 | protected postUploadRequest (options: InternalCommonCommandOptions & { |
120 | fields?: { [ fieldName: string ]: any } | 114 | fields?: { [ fieldName: string ]: any } |
121 | attaches?: { [ fieldName: string ]: any } | 115 | attaches?: { [ fieldName: string ]: any } |
122 | headers?: { [ name: string ]: string } | ||
123 | }) { | 116 | }) { |
124 | const { fields, attaches, headers } = options | 117 | const { fields, attaches } = options |
125 | 118 | ||
126 | return makeUploadRequest({ | 119 | return makeUploadRequest({ |
127 | ...this.buildCommonRequestOptions(options), | 120 | ...this.buildCommonRequestOptions(options), |
128 | 121 | ||
129 | method: 'POST', | 122 | method: 'POST', |
130 | fields, | 123 | fields, |
131 | attaches, | 124 | attaches |
132 | headers | ||
133 | }) | 125 | }) |
134 | } | 126 | } |
135 | 127 | ||
136 | protected putUploadRequest (options: InternalCommonCommandOptions & { | 128 | protected putUploadRequest (options: InternalCommonCommandOptions & { |
137 | fields?: { [ fieldName: string ]: any } | 129 | fields?: { [ fieldName: string ]: any } |
138 | attaches?: { [ fieldName: string ]: any } | 130 | attaches?: { [ fieldName: string ]: any } |
139 | headers?: { [ name: string ]: string } | ||
140 | }) { | 131 | }) { |
141 | const { fields, attaches, headers } = options | 132 | const { fields, attaches } = options |
142 | 133 | ||
143 | return makeUploadRequest({ | 134 | return makeUploadRequest({ |
144 | ...this.buildCommonRequestOptions(options), | 135 | ...this.buildCommonRequestOptions(options), |
145 | 136 | ||
146 | method: 'PUT', | 137 | method: 'PUT', |
147 | headers, | ||
148 | fields, | 138 | fields, |
149 | attaches | 139 | attaches |
150 | }) | 140 | }) |
@@ -154,12 +144,9 @@ abstract class AbstractCommand { | |||
154 | fixture: string | 144 | fixture: string |
155 | fieldname: string | 145 | fieldname: string |
156 | }) { | 146 | }) { |
157 | let filePath = '' | 147 | const filePath = isAbsolute(options.fixture) |
158 | if (isAbsolute(options.fixture)) { | 148 | ? options.fixture |
159 | filePath = options.fixture | 149 | : join(root(), 'server', 'tests', 'fixtures', options.fixture) |
160 | } else { | ||
161 | filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture) | ||
162 | } | ||
163 | 150 | ||
164 | return this.postUploadRequest({ | 151 | return this.postUploadRequest({ |
165 | ...options, | 152 | ...options, |
@@ -170,14 +157,23 @@ abstract class AbstractCommand { | |||
170 | } | 157 | } |
171 | 158 | ||
172 | protected buildCommonRequestOptions (options: InternalCommonCommandOptions) { | 159 | protected buildCommonRequestOptions (options: InternalCommonCommandOptions) { |
173 | const { url, path } = options | 160 | const { url, path, redirects, contentType, accept, range, host, headers, requestType, xForwardedFor } = options |
174 | 161 | ||
175 | return { | 162 | return { |
176 | url: url ?? this.server.url, | 163 | url: url ?? this.server.url, |
177 | path, | 164 | path, |
178 | 165 | ||
179 | token: this.buildCommonRequestToken(options), | 166 | token: this.buildCommonRequestToken(options), |
180 | statusCodeExpected: this.buildStatusCodeExpected(options) | 167 | expectedStatus: this.buildExpectedStatus(options), |
168 | |||
169 | redirects, | ||
170 | contentType, | ||
171 | range, | ||
172 | host, | ||
173 | accept, | ||
174 | headers, | ||
175 | type: requestType, | ||
176 | xForwardedFor | ||
181 | } | 177 | } |
182 | } | 178 | } |
183 | 179 | ||
@@ -191,7 +187,7 @@ abstract class AbstractCommand { | |||
191 | return token !== undefined ? token : fallbackToken | 187 | return token !== undefined ? token : fallbackToken |
192 | } | 188 | } |
193 | 189 | ||
194 | protected buildStatusCodeExpected (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) { | 190 | protected buildExpectedStatus (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) { |
195 | const { expectedStatus, defaultExpectedStatus } = options | 191 | const { expectedStatus, defaultExpectedStatus } = options |
196 | 192 | ||
197 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus | 193 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus |
diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts index 4cd1d2158..08977e58b 100644 --- a/shared/extra-utils/users/accounts-command.ts +++ b/shared/extra-utils/users/accounts-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Account } from '../../models/actors' | 3 | import { Account } from '../../models/actors' |
4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' | 4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts index 089b5a579..a9431acf3 100644 --- a/shared/extra-utils/users/blocklist-command.ts +++ b/shared/extra-utils/users/blocklist-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' | 4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/users/index.ts b/shared/extra-utils/users/index.ts index e6107afa5..fbb454e8f 100644 --- a/shared/extra-utils/users/index.ts +++ b/shared/extra-utils/users/index.ts | |||
@@ -7,4 +7,3 @@ export * from './notifications' | |||
7 | export * from './notifications-command' | 7 | export * from './notifications-command' |
8 | export * from './subscriptions-command' | 8 | export * from './subscriptions-command' |
9 | export * from './users-command' | 9 | export * from './users-command' |
10 | export * from './users' | ||
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index 10c3db851..b39577260 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { PeerTubeProblemDocument } from '@shared/models' | 2 | import { PeerTubeProblemDocument } from '@shared/models' |
3 | import { unwrapBody } from '../requests' | 3 | import { unwrapBody } from '../requests' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
@@ -26,7 +26,7 @@ export class LoginCommand extends AbstractCommand { | |||
26 | ...options, | 26 | ...options, |
27 | 27 | ||
28 | path, | 28 | path, |
29 | type: 'form', | 29 | requestType: 'form', |
30 | fields: body, | 30 | fields: body, |
31 | implicitToken: false, | 31 | implicitToken: false, |
32 | defaultExpectedStatus: HttpStatusCode.OK_200 | 32 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -72,7 +72,7 @@ export class LoginCommand extends AbstractCommand { | |||
72 | ...options, | 72 | ...options, |
73 | 73 | ||
74 | path, | 74 | path, |
75 | type: 'form', | 75 | requestType: 'form', |
76 | fields: body, | 76 | fields: body, |
77 | implicitToken: false, | 77 | implicitToken: false, |
78 | defaultExpectedStatus: HttpStatusCode.OK_200 | 78 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -88,7 +88,7 @@ export class LoginCommand extends AbstractCommand { | |||
88 | ...options, | 88 | ...options, |
89 | 89 | ||
90 | path, | 90 | path, |
91 | type: 'form', | 91 | requestType: 'form', |
92 | implicitToken: false, | 92 | implicitToken: false, |
93 | defaultExpectedStatus: HttpStatusCode.OK_200 | 93 | defaultExpectedStatus: HttpStatusCode.OK_200 |
94 | })) | 94 | })) |
@@ -111,7 +111,7 @@ export class LoginCommand extends AbstractCommand { | |||
111 | ...options, | 111 | ...options, |
112 | 112 | ||
113 | path, | 113 | path, |
114 | type: 'form', | 114 | requestType: 'form', |
115 | fields: body, | 115 | fields: body, |
116 | implicitToken: false, | 116 | implicitToken: false, |
117 | defaultExpectedStatus: HttpStatusCode.OK_200 | 117 | defaultExpectedStatus: HttpStatusCode.OK_200 |
diff --git a/shared/extra-utils/users/notifications-command.ts b/shared/extra-utils/users/notifications-command.ts index dfe574ca1..a51fcc3af 100644 --- a/shared/extra-utils/users/notifications-command.ts +++ b/shared/extra-utils/users/notifications-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { UserNotification, UserNotificationSetting } from '../../models/users' | 3 | import { UserNotification, UserNotificationSetting } from '../../models/users' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts index e998eb426..a69d2a194 100644 --- a/shared/extra-utils/users/subscriptions-command.ts +++ b/shared/extra-utils/users/subscriptions-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList, Video, VideoChannel } from '@shared/models' | 1 | import { ResultList, Video, VideoChannel } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class SubscriptionsCommand extends AbstractCommand { | 5 | export class SubscriptionsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index 59dc6d018..f3a251e65 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit, pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/core-utils' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { | 3 | import { |
4 | MyUser, | 4 | MyUser, |
5 | ResultList, | 5 | ResultList, |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts deleted file mode 100644 index 6cf61d60e..000000000 --- a/shared/extra-utils/users/users.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | |||
4 | // FIXME: delete once videos does not use it anymore | ||
5 | function xxxgetMyUserInformation (url: string, accessToken: string, specialStatus = HttpStatusCode.OK_200) { | ||
6 | const path = '/api/v1/users/me' | ||
7 | |||
8 | return request(url) | ||
9 | .get(path) | ||
10 | .set('Accept', 'application/json') | ||
11 | .set('Authorization', 'Bearer ' + accessToken) | ||
12 | .expect(specialStatus) | ||
13 | .expect('Content-Type', /json/) | ||
14 | } | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | export { | ||
19 | xxxgetMyUserInformation | ||
20 | } | ||
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts index fdae6b469..9404d4c08 100644 --- a/shared/extra-utils/videos/blacklist-command.ts +++ b/shared/extra-utils/videos/blacklist-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { ResultList } from '@shared/models' | 2 | import { ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' | 4 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts index ac3bde7a9..04dd32f84 100644 --- a/shared/extra-utils/videos/captions-command.ts +++ b/shared/extra-utils/videos/captions-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { ResultList, VideoCaption } from '@shared/models' | 2 | import { ResultList, VideoCaption } from '@shared/models' |
3 | import { buildAbsoluteFixturePath } from '../miscs' | 3 | import { buildAbsoluteFixturePath } from '../miscs' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/captions.ts b/shared/extra-utils/videos/captions.ts index 2246bd133..ff8a43366 100644 --- a/shared/extra-utils/videos/captions.ts +++ b/shared/extra-utils/videos/captions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { | 5 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { |
6 | const res = await request(url) | 6 | const res = await request(url) |
diff --git a/shared/extra-utils/videos/change-ownership-command.ts b/shared/extra-utils/videos/change-ownership-command.ts index 03f77a95f..ef6f07536 100644 --- a/shared/extra-utils/videos/change-ownership-command.ts +++ b/shared/extra-utils/videos/change-ownership-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { ResultList, VideoChangeOwnership } from '@shared/models' | 2 | import { ResultList, VideoChangeOwnership } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
6 | export class ChangeOwnershipCommand extends AbstractCommand { | 6 | export class ChangeOwnershipCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts index a98c5cc93..e5393ff56 100644 --- a/shared/extra-utils/videos/channels-command.ts +++ b/shared/extra-utils/videos/channels-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' | 2 | import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' | 4 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' |
5 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' | 5 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' |
6 | import { unwrapBody } from '../requests' | 6 | import { unwrapBody } from '../requests' |
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts index b31f3e2dd..7368f3ea2 100644 --- a/shared/extra-utils/videos/comments-command.ts +++ b/shared/extra-utils/videos/comments-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' | 3 | import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { unwrapBody } from '../requests' | 4 | import { unwrapBody } from '../requests' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts index 8a144a312..41afc6bc6 100644 --- a/shared/extra-utils/videos/history-command.ts +++ b/shared/extra-utils/videos/history-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
1 | import { ResultList, Video } from '@shared/models' | 2 | import { ResultList, Video } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class HistoryCommand extends AbstractCommand { | 5 | export class HistoryCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts index de8b65829..d30f9745b 100644 --- a/shared/extra-utils/videos/imports-command.ts +++ b/shared/extra-utils/videos/imports-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { ResultList } from '@shared/models' | 3 | import { ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { VideoImport, VideoImportCreate } from '../../models/videos' | 4 | import { VideoImport, VideoImportCreate } from '../../models/videos' |
5 | import { unwrapBody } from '../requests' | 5 | import { unwrapBody } from '../requests' |
6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index fd66c9924..9dfe3087e 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import { readdir } from 'fs-extra' | 3 | import { readdir } from 'fs-extra' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { HttpStatusCode } from '@shared/models' | ||
6 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' | 7 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' |
7 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
8 | import { wait } from '../miscs' | 8 | import { wait } from '../miscs' |
9 | import { unwrapBody } from '../requests' | 9 | import { unwrapBody } from '../requests' |
10 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 10 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts index cbfc7e10f..40162c30d 100644 --- a/shared/extra-utils/videos/playlists-command.ts +++ b/shared/extra-utils/videos/playlists-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit, pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/core-utils' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { | 3 | import { |
4 | BooleanBothQuery, | 4 | BooleanBothQuery, |
5 | ResultList, | 5 | ResultList, |
diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts index 313b7878c..06760df42 100644 --- a/shared/extra-utils/videos/services-command.ts +++ b/shared/extra-utils/videos/services-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
3 | 3 | ||
4 | export class ServicesCommand extends AbstractCommand { | 4 | export class ServicesCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/streaming-playlists-command.ts b/shared/extra-utils/videos/streaming-playlists-command.ts index fab3eb556..9662685da 100644 --- a/shared/extra-utils/videos/streaming-playlists-command.ts +++ b/shared/extra-utils/videos/streaming-playlists-command.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | 1 | import { HttpStatusCode } from '@shared/models' | |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
3 | import { unwrapBody, unwrapText } from '../requests' | 2 | import { unwrapBody, unwrapText } from '../requests' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 4 | ||
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index 002ae08b2..007d3d98d 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { sha256 } from '@server/helpers/core-utils' | 2 | import { sha256 } from '@server/helpers/core-utils' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoStreamingPlaylist } from '@shared/models' | 4 | import { VideoStreamingPlaylist } from '@shared/models' |
5 | import { PeerTubeServer } from '../server' | 5 | import { PeerTubeServer } from '../server' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index feef5a771..f46d386f4 100644 --- a/shared/extra-utils/videos/videos-command.ts +++ b/shared/extra-utils/videos/videos-command.ts | |||
@@ -7,7 +7,7 @@ import { omit, pick } from 'lodash' | |||
7 | import validator from 'validator' | 7 | import validator from 'validator' |
8 | import { buildUUID } from '@server/helpers/uuid' | 8 | import { buildUUID } from '@server/helpers/uuid' |
9 | import { loadLanguages } from '@server/initializers/constants' | 9 | import { loadLanguages } from '@server/initializers/constants' |
10 | import { HttpStatusCode } from '@shared/core-utils' | 10 | import { HttpStatusCode } from '@shared/models' |
11 | import { | 11 | import { |
12 | ResultList, | 12 | ResultList, |
13 | UserVideoRateType, | 13 | UserVideoRateType, |
@@ -234,10 +234,10 @@ export class VideosCommand extends AbstractCommand { | |||
234 | } | 234 | } |
235 | 235 | ||
236 | listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { | 236 | listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { |
237 | accountName: string | 237 | handle: string |
238 | }) { | 238 | }) { |
239 | const { accountName, search } = options | 239 | const { handle, search } = options |
240 | const path = '/api/v1/accounts/' + accountName + '/videos' | 240 | const path = '/api/v1/accounts/' + handle + '/videos' |
241 | 241 | ||
242 | return this.getRequestBody<ResultList<Video>>({ | 242 | return this.getRequestBody<ResultList<Video>>({ |
243 | ...options, | 243 | ...options, |
@@ -250,10 +250,10 @@ export class VideosCommand extends AbstractCommand { | |||
250 | } | 250 | } |
251 | 251 | ||
252 | listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { | 252 | listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { |
253 | videoChannelName: string | 253 | handle: string |
254 | }) { | 254 | }) { |
255 | const { videoChannelName } = options | 255 | const { handle } = options |
256 | const path = '/api/v1/video-channels/' + videoChannelName + '/videos' | 256 | const path = '/api/v1/video-channels/' + handle + '/videos' |
257 | 257 | ||
258 | return this.getRequestBody<ResultList<Video>>({ | 258 | return this.getRequestBody<ResultList<Video>>({ |
259 | ...options, | 259 | ...options, |
@@ -309,13 +309,13 @@ export class VideosCommand extends AbstractCommand { | |||
309 | }) { | 309 | }) { |
310 | const path = '/api/v1/videos/' + options.id | 310 | const path = '/api/v1/videos/' + options.id |
311 | 311 | ||
312 | return this.deleteRequest({ | 312 | return unwrapBody(this.deleteRequest({ |
313 | ...options, | 313 | ...options, |
314 | 314 | ||
315 | path, | 315 | path, |
316 | implicitToken: true, | 316 | implicitToken: true, |
317 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | 317 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 |
318 | }) | 318 | })) |
319 | } | 319 | } |
320 | 320 | ||
321 | async removeAll () { | 321 | async removeAll () { |
@@ -396,7 +396,7 @@ export class VideosCommand extends AbstractCommand { | |||
396 | 396 | ||
397 | async buildResumeUpload (options: OverrideCommandOptions & { | 397 | async buildResumeUpload (options: OverrideCommandOptions & { |
398 | attributes: VideoEdit | 398 | attributes: VideoEdit |
399 | }) { | 399 | }): Promise<VideoCreateResult> { |
400 | const { attributes, expectedStatus } = options | 400 | const { attributes, expectedStatus } = options |
401 | 401 | ||
402 | let size = 0 | 402 | let size = 0 |
@@ -414,7 +414,8 @@ export class VideosCommand extends AbstractCommand { | |||
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | const initializeSessionRes = await this.prepareResumableUpload({ ...options, attributes, size, mimetype }) | 417 | // Do not check status automatically, we'll check it manually |
418 | const initializeSessionRes = await this.prepareResumableUpload({ ...options, expectedStatus: null, attributes, size, mimetype }) | ||
418 | const initStatus = initializeSessionRes.status | 419 | const initStatus = initializeSessionRes.status |
419 | 420 | ||
420 | if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) { | 421 | if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) { |
@@ -425,7 +426,7 @@ export class VideosCommand extends AbstractCommand { | |||
425 | 426 | ||
426 | const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) | 427 | const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) |
427 | 428 | ||
428 | return result.body.video | 429 | return result.body?.video || result.body as any |
429 | } | 430 | } |
430 | 431 | ||
431 | const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200 | 432 | const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200 |
@@ -434,7 +435,7 @@ export class VideosCommand extends AbstractCommand { | |||
434 | 435 | ||
435 | expect(initStatus).to.equal(expectedInitStatus) | 436 | expect(initStatus).to.equal(expectedInitStatus) |
436 | 437 | ||
437 | return initializeSessionRes.body.video as VideoCreateResult | 438 | return initializeSessionRes.body.video || initializeSessionRes.body |
438 | } | 439 | } |
439 | 440 | ||
440 | async prepareResumableUpload (options: OverrideCommandOptions & { | 441 | async prepareResumableUpload (options: OverrideCommandOptions & { |
@@ -455,7 +456,10 @@ export class VideosCommand extends AbstractCommand { | |||
455 | 'X-Upload-Content-Length': size.toString() | 456 | 'X-Upload-Content-Length': size.toString() |
456 | }, | 457 | }, |
457 | fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) }, | 458 | fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) }, |
459 | // Fixture will be sent later | ||
460 | attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')), | ||
458 | implicitToken: true, | 461 | implicitToken: true, |
462 | |||
459 | defaultExpectedStatus: null | 463 | defaultExpectedStatus: null |
460 | }) | 464 | }) |
461 | } | 465 | } |
@@ -539,10 +543,10 @@ export class VideosCommand extends AbstractCommand { | |||
539 | 543 | ||
540 | const attributes = { name, additionalParams } | 544 | const attributes = { name, additionalParams } |
541 | 545 | ||
542 | if (wait) await waitJobs([ this.server ]) | ||
543 | |||
544 | const result = await this.upload({ ...options, attributes }) | 546 | const result = await this.upload({ ...options, attributes }) |
545 | 547 | ||
548 | if (wait) await waitJobs([ this.server ]) | ||
549 | |||
546 | return { ...result, name } | 550 | return { ...result, name } |
547 | } | 551 | } |
548 | 552 | ||
@@ -566,7 +570,7 @@ export class VideosCommand extends AbstractCommand { | |||
566 | } | 570 | } |
567 | 571 | ||
568 | private buildUploadFields (attributes: VideoEdit) { | 572 | private buildUploadFields (attributes: VideoEdit) { |
569 | return omit(attributes, [ 'thumbnailfile', 'previewfile' ]) | 573 | return omit(attributes, [ 'fixture', 'thumbnailfile', 'previewfile' ]) |
570 | } | 574 | } |
571 | 575 | ||
572 | private buildUploadAttaches (attributes: VideoEdit) { | 576 | private buildUploadAttaches (attributes: VideoEdit) { |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b41533808..a96073c56 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 6 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' | 8 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' |
9 | import { dateIsValid, testImage, webtorrentAdd } from '../miscs' | 9 | import { dateIsValid, testImage, webtorrentAdd } from '../miscs' |
10 | import { makeRawRequest } from '../requests/requests' | 10 | import { makeRawRequest } from '../requests/requests' |
diff --git a/shared/core-utils/miscs/http-error-codes.ts b/shared/models/http/http-error-codes.ts index b2fbdfc5a..b2fbdfc5a 100644 --- a/shared/core-utils/miscs/http-error-codes.ts +++ b/shared/models/http/http-error-codes.ts | |||
diff --git a/shared/core-utils/miscs/http-methods.ts b/shared/models/http/http-methods.ts index 1cfa458b9..1cfa458b9 100644 --- a/shared/core-utils/miscs/http-methods.ts +++ b/shared/models/http/http-methods.ts | |||
diff --git a/shared/models/http/index.ts b/shared/models/http/index.ts new file mode 100644 index 000000000..ec991afe0 --- /dev/null +++ b/shared/models/http/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './http-error-codes' | ||
2 | export * from './http-methods' | ||
diff --git a/shared/models/index.ts b/shared/models/index.ts index 5c2bc480e..78723d830 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -4,6 +4,7 @@ export * from './bulk' | |||
4 | export * from './common' | 4 | export * from './common' |
5 | export * from './custom-markup' | 5 | export * from './custom-markup' |
6 | export * from './feeds' | 6 | export * from './feeds' |
7 | export * from './http' | ||
7 | export * from './joinpeertube' | 8 | export * from './joinpeertube' |
8 | export * from './moderation' | 9 | export * from './moderation' |
9 | export * from './overviews' | 10 | export * from './overviews' |
diff --git a/shared/models/server/peertube-problem-document.model.ts b/shared/models/server/peertube-problem-document.model.ts index e391d5aad..8dd96f7a3 100644 --- a/shared/models/server/peertube-problem-document.model.ts +++ b/shared/models/server/peertube-problem-document.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils' | 1 | import { HttpStatusCode } from '../../models' |
2 | import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' | 2 | import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' |
3 | 3 | ||
4 | export interface PeerTubeProblemDocumentData { | 4 | export interface PeerTubeProblemDocumentData { |