aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/server/servers.ts4
-rw-r--r--shared/extra-utils/videos/blacklist-command.ts77
-rw-r--r--shared/extra-utils/videos/index.ts2
-rw-r--r--shared/extra-utils/videos/video-blacklist.ts79
4 files changed, 81 insertions, 81 deletions
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts
index cb2a8814b..a4432902f 100644
--- a/shared/extra-utils/server/servers.ts
+++ b/shared/extra-utils/server/servers.ts
@@ -18,7 +18,7 @@ import { makeGetRequest } from '../requests/requests'
18import { SearchCommand } from '../search' 18import { SearchCommand } from '../search'
19import { SocketIOCommand } from '../socket' 19import { SocketIOCommand } from '../socket'
20import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users' 20import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
21import { LiveCommand, ServicesCommand } from '../videos' 21import { LiveCommand, ServicesCommand, BlacklistCommand } from '../videos'
22import { ConfigCommand } from './config-command' 22import { ConfigCommand } from './config-command'
23import { ContactFormCommand } from './contact-form-command' 23import { ContactFormCommand } from './contact-form-command'
24import { DebugCommand } from './debug-command' 24import { DebugCommand } from './debug-command'
@@ -102,6 +102,7 @@ interface ServerInfo {
102 subscriptionsCommand?: SubscriptionsCommand 102 subscriptionsCommand?: SubscriptionsCommand
103 liveCommand?: LiveCommand 103 liveCommand?: LiveCommand
104 servicesCommand?: ServicesCommand 104 servicesCommand?: ServicesCommand
105 blacklistCommand?: BlacklistCommand
105} 106}
106 107
107function parallelTests () { 108function parallelTests () {
@@ -329,6 +330,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
329 server.subscriptionsCommand = new SubscriptionsCommand(server) 330 server.subscriptionsCommand = new SubscriptionsCommand(server)
330 server.liveCommand = new LiveCommand(server) 331 server.liveCommand = new LiveCommand(server)
331 server.servicesCommand = new ServicesCommand(server) 332 server.servicesCommand = new ServicesCommand(server)
333 server.blacklistCommand = new BlacklistCommand(server)
332 334
333 res(server) 335 res(server)
334 }) 336 })
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts
new file mode 100644
index 000000000..fdae6b469
--- /dev/null
+++ b/shared/extra-utils/videos/blacklist-command.ts
@@ -0,0 +1,77 @@
1
2import { ResultList } from '@shared/models'
3import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
4import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
5import { AbstractCommand, OverrideCommandOptions } from '../shared'
6
7export class BlacklistCommand extends AbstractCommand {
8
9 add (options: OverrideCommandOptions & {
10 videoId: number | string
11 reason?: string
12 unfederate?: boolean
13 }) {
14 const { videoId, reason, unfederate } = options
15 const path = '/api/v1/videos/' + videoId + '/blacklist'
16
17 return this.postBodyRequest({
18 ...options,
19
20 path,
21 fields: { reason, unfederate },
22 implicitToken: true,
23 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
24 })
25 }
26
27 update (options: OverrideCommandOptions & {
28 videoId: number | string
29 reason?: string
30 }) {
31 const { videoId, reason } = options
32 const path = '/api/v1/videos/' + videoId + '/blacklist'
33
34 return this.putBodyRequest({
35 ...options,
36
37 path,
38 fields: { reason },
39 implicitToken: true,
40 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
41 })
42 }
43
44 remove (options: OverrideCommandOptions & {
45 videoId: number | string
46 }) {
47 const { videoId } = options
48 const path = '/api/v1/videos/' + videoId + '/blacklist'
49
50 return this.deleteRequest({
51 ...options,
52
53 path,
54 implicitToken: true,
55 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
56 })
57 }
58
59 list (options: OverrideCommandOptions & {
60 sort?: string
61 type?: VideoBlacklistType
62 } = {}) {
63 const { sort, type } = options
64 const path = '/api/v1/videos/blacklist/'
65
66 const query = { sort, type }
67
68 return this.getRequestBody<ResultList<VideoBlacklist>>({
69 ...options,
70
71 path,
72 query,
73 implicitToken: true,
74 defaultExpectedStatus: HttpStatusCode.OK_200
75 })
76 }
77}
diff --git a/shared/extra-utils/videos/index.ts b/shared/extra-utils/videos/index.ts
index fe5dc6655..67f5faf54 100644
--- a/shared/extra-utils/videos/index.ts
+++ b/shared/extra-utils/videos/index.ts
@@ -1,7 +1,7 @@
1export * from './blacklist-command'
1export * from './live-command' 2export * from './live-command'
2export * from './live' 3export * from './live'
3export * from './services-command' 4export * from './services-command'
4export * from './video-blacklist'
5export * from './video-captions' 5export * from './video-captions'
6export * from './video-change-ownership' 6export * from './video-change-ownership'
7export * from './video-channels' 7export * from './video-channels'
diff --git a/shared/extra-utils/videos/video-blacklist.ts b/shared/extra-utils/videos/video-blacklist.ts
deleted file mode 100644
index aa1548537..000000000
--- a/shared/extra-utils/videos/video-blacklist.ts
+++ /dev/null
@@ -1,79 +0,0 @@
1import * as request from 'supertest'
2import { VideoBlacklistType } from '../../models/videos'
3import { makeGetRequest } from '..'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
5
6function addVideoToBlacklist (
7 url: string,
8 token: string,
9 videoId: number | string,
10 reason?: string,
11 unfederate?: boolean,
12 specialStatus = HttpStatusCode.NO_CONTENT_204
13) {
14 const path = '/api/v1/videos/' + videoId + '/blacklist'
15
16 return request(url)
17 .post(path)
18 .send({ reason, unfederate })
19 .set('Accept', 'application/json')
20 .set('Authorization', 'Bearer ' + token)
21 .expect(specialStatus)
22}
23
24function updateVideoBlacklist (
25 url: string,
26 token: string,
27 videoId: number,
28 reason?: string,
29 specialStatus = HttpStatusCode.NO_CONTENT_204
30) {
31 const path = '/api/v1/videos/' + videoId + '/blacklist'
32
33 return request(url)
34 .put(path)
35 .send({ reason })
36 .set('Accept', 'application/json')
37 .set('Authorization', 'Bearer ' + token)
38 .expect(specialStatus)
39}
40
41function removeVideoFromBlacklist (url: string, token: string, videoId: number | string, specialStatus = HttpStatusCode.NO_CONTENT_204) {
42 const path = '/api/v1/videos/' + videoId + '/blacklist'
43
44 return request(url)
45 .delete(path)
46 .set('Accept', 'application/json')
47 .set('Authorization', 'Bearer ' + token)
48 .expect(specialStatus)
49}
50
51function getBlacklistedVideosList (parameters: {
52 url: string
53 token: string
54 sort?: string
55 type?: VideoBlacklistType
56 specialStatus?: HttpStatusCode
57}) {
58 const { url, token, sort, type, specialStatus = HttpStatusCode.OK_200 } = parameters
59 const path = '/api/v1/videos/blacklist/'
60
61 const query = { sort, type }
62
63 return makeGetRequest({
64 url,
65 path,
66 query,
67 token,
68 statusCodeExpected: specialStatus
69 })
70}
71
72// ---------------------------------------------------------------------------
73
74export {
75 addVideoToBlacklist,
76 removeVideoFromBlacklist,
77 getBlacklistedVideosList,
78 updateVideoBlacklist
79}