diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 09:29:23 +0100 |
commit | bf54587a3e2ad9c2c186828f2a5682b91ee2cc00 (patch) | |
tree | 54b40aaf01bae210632473285c3c7571d51e4f89 /shared/server-commands/videos/change-ownership-command.ts | |
parent | 6b5f72beda96d8b7e4d6329c4001827334de27dd (diff) | |
download | PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.gz PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.tar.zst PeerTube-bf54587a3e2ad9c2c186828f2a5682b91ee2cc00.zip |
shared/ typescript types dir server-commands
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 | } | ||