]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/extra-utils/videos/blacklist-command.ts
Introduce history command
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / blacklist-command.ts
1
2 import { ResultList } from '@shared/models'
3 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
4 import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
5 import { AbstractCommand, OverrideCommandOptions } from '../shared'
6
7 export 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 }