diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-15 15:26:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:25:52 +0200 |
commit | 94565d52bb2883e09f16d1363170ac9c0dccb7a1 (patch) | |
tree | 3dcd20cd7b5a5cca80bce32b655cdbfaddf7aa59 /shared/utils/videos/video-comments.ts | |
parent | 4ee7a4c9ac9280cda930a281c2d5a9a4c409cc14 (diff) | |
download | PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.gz PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.tar.zst PeerTube-94565d52bb2883e09f16d1363170ac9c0dccb7a1.zip |
Shared utils -> extra-utils
Because they need dev dependencies
Diffstat (limited to 'shared/utils/videos/video-comments.ts')
-rw-r--r-- | shared/utils/videos/video-comments.ts | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/shared/utils/videos/video-comments.ts b/shared/utils/videos/video-comments.ts deleted file mode 100644 index 0ebf69ced..000000000 --- a/shared/utils/videos/video-comments.ts +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { makeDeleteRequest } from '../requests/requests' | ||
3 | |||
4 | function getVideoCommentThreads (url: string, videoId: number | string, start: number, count: number, sort?: string, token?: string) { | ||
5 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | ||
6 | |||
7 | const req = request(url) | ||
8 | .get(path) | ||
9 | .query({ start: start }) | ||
10 | .query({ count: count }) | ||
11 | |||
12 | if (sort) req.query({ sort }) | ||
13 | if (token) req.set('Authorization', 'Bearer ' + token) | ||
14 | |||
15 | return req.set('Accept', 'application/json') | ||
16 | .expect(200) | ||
17 | .expect('Content-Type', /json/) | ||
18 | } | ||
19 | |||
20 | function getVideoThreadComments (url: string, videoId: number | string, threadId: number, token?: string) { | ||
21 | const path = '/api/v1/videos/' + videoId + '/comment-threads/' + threadId | ||
22 | |||
23 | const req = request(url) | ||
24 | .get(path) | ||
25 | .set('Accept', 'application/json') | ||
26 | |||
27 | if (token) req.set('Authorization', 'Bearer ' + token) | ||
28 | |||
29 | return req.expect(200) | ||
30 | .expect('Content-Type', /json/) | ||
31 | } | ||
32 | |||
33 | function addVideoCommentThread (url: string, token: string, videoId: number | string, text: string, expectedStatus = 200) { | ||
34 | const path = '/api/v1/videos/' + videoId + '/comment-threads' | ||
35 | |||
36 | return request(url) | ||
37 | .post(path) | ||
38 | .send({ text }) | ||
39 | .set('Accept', 'application/json') | ||
40 | .set('Authorization', 'Bearer ' + token) | ||
41 | .expect(expectedStatus) | ||
42 | } | ||
43 | |||
44 | function addVideoCommentReply ( | ||
45 | url: string, | ||
46 | token: string, | ||
47 | videoId: number | string, | ||
48 | inReplyToCommentId: number, | ||
49 | text: string, | ||
50 | expectedStatus = 200 | ||
51 | ) { | ||
52 | const path = '/api/v1/videos/' + videoId + '/comments/' + inReplyToCommentId | ||
53 | |||
54 | return request(url) | ||
55 | .post(path) | ||
56 | .send({ text }) | ||
57 | .set('Accept', 'application/json') | ||
58 | .set('Authorization', 'Bearer ' + token) | ||
59 | .expect(expectedStatus) | ||
60 | } | ||
61 | |||
62 | function deleteVideoComment ( | ||
63 | url: string, | ||
64 | token: string, | ||
65 | videoId: number | string, | ||
66 | commentId: number, | ||
67 | statusCodeExpected = 204 | ||
68 | ) { | ||
69 | const path = '/api/v1/videos/' + videoId + '/comments/' + commentId | ||
70 | |||
71 | return makeDeleteRequest({ | ||
72 | url, | ||
73 | path, | ||
74 | token, | ||
75 | statusCodeExpected | ||
76 | }) | ||
77 | } | ||
78 | |||
79 | // --------------------------------------------------------------------------- | ||
80 | |||
81 | export { | ||
82 | getVideoCommentThreads, | ||
83 | getVideoThreadComments, | ||
84 | addVideoCommentThread, | ||
85 | addVideoCommentReply, | ||
86 | deleteVideoComment | ||
87 | } | ||