aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 14:30:20 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commit23a3a8827cb8b862f5cc7ee2819f39918303beca (patch)
tree93a3bdbd02787d32094d6d50aa209f2c079038a5 /shared
parent480d6ea6791fe4100f1905af1e1e3a08173594ea (diff)
downloadPeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.tar.gz
PeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.tar.zst
PeerTube-23a3a8827cb8b862f5cc7ee2819f39918303beca.zip
Introduce overviews command
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/index.ts1
-rw-r--r--shared/extra-utils/overviews/index.ts1
-rw-r--r--shared/extra-utils/overviews/overviews-command.ts25
-rw-r--r--shared/extra-utils/overviews/overviews.ts34
-rw-r--r--shared/extra-utils/server/servers.ts3
-rw-r--r--shared/extra-utils/shared/abstract-command.ts5
6 files changed, 34 insertions, 35 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 7ca079c78..38c8c4c1c 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -6,6 +6,7 @@ export * from './logs'
6export * from './miscs' 6export * from './miscs'
7export * from './mock-servers' 7export * from './mock-servers'
8export * from './moderation' 8export * from './moderation'
9export * from './overviews'
9 10
10export * from './requests/check-api-params' 11export * from './requests/check-api-params'
11export * from './requests/requests' 12export * from './requests/requests'
diff --git a/shared/extra-utils/overviews/index.ts b/shared/extra-utils/overviews/index.ts
new file mode 100644
index 000000000..e19551907
--- /dev/null
+++ b/shared/extra-utils/overviews/index.ts
@@ -0,0 +1 @@
export * from './overviews-command'
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts
new file mode 100644
index 000000000..0ac3cbd33
--- /dev/null
+++ b/shared/extra-utils/overviews/overviews-command.ts
@@ -0,0 +1,25 @@
1import { HttpStatusCode } from '@shared/core-utils'
2import { VideosOverview } from '@shared/models'
3import { AbstractCommand, OverrideCommandOptions } from '../shared'
4
5export class OverviewsCommand extends AbstractCommand {
6
7 getVideos (options: OverrideCommandOptions & {
8 page: number
9 token?: string
10 }) {
11 const { token, page } = options
12 const path = '/api/v1/overviews/videos'
13
14 const query = { page }
15
16 return this.getRequestBody<VideosOverview>({
17 ...options,
18
19 token: token || null,
20 path,
21 query,
22 defaultExpectedStatus: HttpStatusCode.OK_200
23 })
24 }
25}
diff --git a/shared/extra-utils/overviews/overviews.ts b/shared/extra-utils/overviews/overviews.ts
deleted file mode 100644
index 5e1a13e5e..000000000
--- a/shared/extra-utils/overviews/overviews.ts
+++ /dev/null
@@ -1,34 +0,0 @@
1import { makeGetRequest } from '../requests/requests'
2import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3
4function getVideosOverview (url: string, page: number, statusCodeExpected = HttpStatusCode.OK_200) {
5 const path = '/api/v1/overviews/videos'
6
7 const query = { page }
8
9 return makeGetRequest({
10 url,
11 path,
12 query,
13 statusCodeExpected
14 })
15}
16
17function getVideosOverviewWithToken (url: string, page: number, token: string, statusCodeExpected = HttpStatusCode.OK_200) {
18 const path = '/api/v1/overviews/videos'
19
20 const query = { page }
21
22 return makeGetRequest({
23 url,
24 path,
25 query,
26 token,
27 statusCodeExpected
28 })
29}
30
31export {
32 getVideosOverview,
33 getVideosOverviewWithToken
34}
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index f05f0dbbe..70be96cf6 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -13,6 +13,7 @@ import { FeedCommand } from '../feeds'
13import { LogsCommand } from '../logs' 13import { LogsCommand } from '../logs'
14import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs' 14import { buildServerDirectory, getFileSize, isGithubCI, root, wait } from '../miscs/miscs'
15import { AbusesCommand } from '../moderation' 15import { AbusesCommand } from '../moderation'
16import { OverviewsCommand } from '../overviews'
16import { makeGetRequest } from '../requests/requests' 17import { makeGetRequest } from '../requests/requests'
17 18
18interface ServerInfo { 19interface ServerInfo {
@@ -73,6 +74,7 @@ interface ServerInfo {
73 feedCommand?: FeedCommand 74 feedCommand?: FeedCommand
74 logsCommand?: LogsCommand 75 logsCommand?: LogsCommand
75 abusesCommand?: AbusesCommand 76 abusesCommand?: AbusesCommand
77 overviewsCommand?: OverviewsCommand
76} 78}
77 79
78function parallelTests () { 80function parallelTests () {
@@ -284,6 +286,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
284 server.feedCommand = new FeedCommand(server) 286 server.feedCommand = new FeedCommand(server)
285 server.logsCommand = new LogsCommand(server) 287 server.logsCommand = new LogsCommand(server)
286 server.abusesCommand = new AbusesCommand(server) 288 server.abusesCommand = new AbusesCommand(server)
289 server.overviewsCommand = new OverviewsCommand(server)
287 290
288 res(server) 291 res(server)
289 }) 292 })
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts
index 3ee5cd865..3815fab0e 100644
--- a/shared/extra-utils/shared/abstract-command.ts
+++ b/shared/extra-utils/shared/abstract-command.ts
@@ -78,7 +78,10 @@ abstract class AbstractCommand {
78 return { 78 return {
79 url: this.server.url, 79 url: this.server.url,
80 path, 80 path,
81 token: token ?? this.server.accessToken, 81
82 // Token can be null if we don't want to add it
83 token: token !== undefined ? token : this.server.accessToken,
84
82 statusCodeExpected: expectedStatus ?? this.expectedStatus ?? defaultExpectedStatus 85 statusCodeExpected: expectedStatus ?? this.expectedStatus ?? defaultExpectedStatus
83 } 86 }
84 } 87 }