aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/server-commands/src/videos/blacklist-command.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/server-commands/src/videos/blacklist-command.ts')
-rw-r--r--packages/server-commands/src/videos/blacklist-command.ts74
1 files changed, 74 insertions, 0 deletions
diff --git a/packages/server-commands/src/videos/blacklist-command.ts b/packages/server-commands/src/videos/blacklist-command.ts
new file mode 100644
index 000000000..d41001e26
--- /dev/null
+++ b/packages/server-commands/src/videos/blacklist-command.ts
@@ -0,0 +1,74 @@
1import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType_Type } from '@peertube/peertube-models'
2import { AbstractCommand, OverrideCommandOptions } from '../shared/index.js'
3
4export class BlacklistCommand extends AbstractCommand {
5
6 add (options: OverrideCommandOptions & {
7 videoId: number | string
8 reason?: string
9 unfederate?: boolean
10 }) {
11 const { videoId, reason, unfederate } = options
12 const path = '/api/v1/videos/' + videoId + '/blacklist'
13
14 return this.postBodyRequest({
15 ...options,
16
17 path,
18 fields: { reason, unfederate },
19 implicitToken: true,
20 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
21 })
22 }
23
24 update (options: OverrideCommandOptions & {
25 videoId: number | string
26 reason?: string
27 }) {
28 const { videoId, reason } = options
29 const path = '/api/v1/videos/' + videoId + '/blacklist'
30
31 return this.putBodyRequest({
32 ...options,
33
34 path,
35 fields: { reason },
36 implicitToken: true,
37 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
38 })
39 }
40
41 remove (options: OverrideCommandOptions & {
42 videoId: number | string
43 }) {
44 const { videoId } = options
45 const path = '/api/v1/videos/' + videoId + '/blacklist'
46
47 return this.deleteRequest({
48 ...options,
49
50 path,
51 implicitToken: true,
52 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
53 })
54 }
55
56 list (options: OverrideCommandOptions & {
57 sort?: string
58 type?: VideoBlacklistType_Type
59 } = {}) {
60 const { sort, type } = options
61 const path = '/api/v1/videos/blacklist/'
62
63 const query = { sort, type }
64
65 return this.getRequestBody<ResultList<VideoBlacklist>>({
66 ...options,
67
68 path,
69 query,
70 implicitToken: true,
71 defaultExpectedStatus: HttpStatusCode.OK_200
72 })
73 }
74}