diff options
Diffstat (limited to 'shared/server-commands/videos/change-ownership-command.ts')
-rw-r--r-- | shared/server-commands/videos/change-ownership-command.ts | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/shared/server-commands/videos/change-ownership-command.ts b/shared/server-commands/videos/change-ownership-command.ts new file mode 100644 index 000000000..ad4c726ef --- /dev/null +++ b/shared/server-commands/videos/change-ownership-command.ts | |||
@@ -0,0 +1,68 @@ | |||
1 | |||
2 | import { HttpStatusCode, ResultList, VideoChangeOwnership } from '@shared/models' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
4 | |||
5 | export class ChangeOwnershipCommand extends AbstractCommand { | ||
6 | |||
7 | create (options: OverrideCommandOptions & { | ||
8 | videoId: number | string | ||
9 | username: string | ||
10 | }) { | ||
11 | const { videoId, username } = options | ||
12 | const path = '/api/v1/videos/' + videoId + '/give-ownership' | ||
13 | |||
14 | return this.postBodyRequest({ | ||
15 | ...options, | ||
16 | |||
17 | path, | ||
18 | fields: { username }, | ||
19 | implicitToken: true, | ||
20 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
21 | }) | ||
22 | } | ||
23 | |||
24 | list (options: OverrideCommandOptions = {}) { | ||
25 | const path = '/api/v1/videos/ownership' | ||
26 | |||
27 | return this.getRequestBody<ResultList<VideoChangeOwnership>>({ | ||
28 | ...options, | ||
29 | |||
30 | path, | ||
31 | query: { sort: '-createdAt' }, | ||
32 | implicitToken: true, | ||
33 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
34 | }) | ||
35 | } | ||
36 | |||
37 | accept (options: OverrideCommandOptions & { | ||
38 | ownershipId: number | ||
39 | channelId: number | ||
40 | }) { | ||
41 | const { ownershipId, channelId } = options | ||
42 | const path = '/api/v1/videos/ownership/' + ownershipId + '/accept' | ||
43 | |||
44 | return this.postBodyRequest({ | ||
45 | ...options, | ||
46 | |||
47 | path, | ||
48 | fields: { channelId }, | ||
49 | implicitToken: true, | ||
50 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
51 | }) | ||
52 | } | ||
53 | |||
54 | refuse (options: OverrideCommandOptions & { | ||
55 | ownershipId: number | ||
56 | }) { | ||
57 | const { ownershipId } = options | ||
58 | const path = '/api/v1/videos/ownership/' + ownershipId + '/refuse' | ||
59 | |||
60 | return this.postBodyRequest({ | ||
61 | ...options, | ||
62 | |||
63 | path, | ||
64 | implicitToken: true, | ||
65 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | ||
66 | }) | ||
67 | } | ||
68 | } | ||