diff options
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 | } | ||