diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /shared/extra-utils/videos/blacklist-command.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'shared/extra-utils/videos/blacklist-command.ts')
-rw-r--r-- | shared/extra-utils/videos/blacklist-command.ts | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts new file mode 100644 index 000000000..3a2ef89ba --- /dev/null +++ b/shared/extra-utils/videos/blacklist-command.ts | |||
@@ -0,0 +1,76 @@ | |||
1 | |||
2 | import { HttpStatusCode, ResultList } from '@shared/models' | ||
3 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
5 | |||
6 | export class BlacklistCommand extends AbstractCommand { | ||
7 | |||
8 | add (options: OverrideCommandOptions & { | ||
9 | videoId: number | string | ||
10 | reason?: string | ||
11 | unfederate?: boolean | ||
12 | }) { | ||
13 | const { videoId, reason, unfederate } = options | ||
14 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
15 | |||
16 | return this.postBodyRequest({ | ||
17 | ...options, | ||
18 | |||
19 | path, | ||
20 | fields: { reason, unfederate }, | ||
21 | implicitToken: true, | ||
22 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
23 | }) | ||
24 | } | ||
25 | |||
26 | update (options: OverrideCommandOptions & { | ||
27 | videoId: number | string | ||
28 | reason?: string | ||
29 | }) { | ||
30 | const { videoId, reason } = options | ||
31 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
32 | |||
33 | return this.putBodyRequest({ | ||
34 | ...options, | ||
35 | |||
36 | path, | ||
37 | fields: { reason }, | ||
38 | implicitToken: true, | ||
39 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | remove (options: OverrideCommandOptions & { | ||
44 | videoId: number | string | ||
45 | }) { | ||
46 | const { videoId } = options | ||
47 | const path = '/api/v1/videos/' + videoId + '/blacklist' | ||
48 | |||
49 | return this.deleteRequest({ | ||
50 | ...options, | ||
51 | |||
52 | path, | ||
53 | implicitToken: true, | ||
54 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
55 | }) | ||
56 | } | ||
57 | |||
58 | list (options: OverrideCommandOptions & { | ||
59 | sort?: string | ||
60 | type?: VideoBlacklistType | ||
61 | } = {}) { | ||
62 | const { sort, type } = options | ||
63 | const path = '/api/v1/videos/blacklist/' | ||
64 | |||
65 | const query = { sort, type } | ||
66 | |||
67 | return this.getRequestBody<ResultList<VideoBlacklist>>({ | ||
68 | ...options, | ||
69 | |||
70 | path, | ||
71 | query, | ||
72 | implicitToken: true, | ||
73 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
74 | }) | ||
75 | } | ||
76 | } | ||