diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
commit | 88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch) | |
tree | b242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /shared/utils/videos/video-history.ts | |
parent | 53a94c7cfa8368da4cd248d65df8346905938f0c (diff) | |
parent | 9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff) | |
download | PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip |
Merge branch 'develop' into pr/1217
Diffstat (limited to 'shared/utils/videos/video-history.ts')
-rw-r--r-- | shared/utils/videos/video-history.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/shared/utils/videos/video-history.ts b/shared/utils/videos/video-history.ts new file mode 100644 index 000000000..dc7095b4d --- /dev/null +++ b/shared/utils/videos/video-history.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | ||
2 | |||
3 | function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) { | ||
4 | const path = '/api/v1/videos/' + videoId + '/watching' | ||
5 | const fields = { currentTime } | ||
6 | |||
7 | return makePutBodyRequest({ url, path, token, fields, statusCodeExpected }) | ||
8 | } | ||
9 | |||
10 | function listMyVideosHistory (url: string, token: string) { | ||
11 | const path = '/api/v1/users/me/history/videos' | ||
12 | |||
13 | return makeGetRequest({ | ||
14 | url, | ||
15 | path, | ||
16 | token, | ||
17 | statusCodeExpected: 200 | ||
18 | }) | ||
19 | } | ||
20 | |||
21 | function removeMyVideosHistory (url: string, token: string, beforeDate?: string) { | ||
22 | const path = '/api/v1/users/me/history/videos/remove' | ||
23 | |||
24 | return makePostBodyRequest({ | ||
25 | url, | ||
26 | path, | ||
27 | token, | ||
28 | fields: beforeDate ? { beforeDate } : {}, | ||
29 | statusCodeExpected: 204 | ||
30 | }) | ||
31 | } | ||
32 | |||
33 | // --------------------------------------------------------------------------- | ||
34 | |||
35 | export { | ||
36 | userWatchVideo, | ||
37 | listMyVideosHistory, | ||
38 | removeMyVideosHistory | ||
39 | } | ||