diff options
Diffstat (limited to 'shared/utils/videos/video-history.ts')
-rw-r--r-- | shared/utils/videos/video-history.ts | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/shared/utils/videos/video-history.ts b/shared/utils/videos/video-history.ts index 7635478f7..dc7095b4d 100644 --- a/shared/utils/videos/video-history.ts +++ b/shared/utils/videos/video-history.ts | |||
@@ -1,14 +1,39 @@ | |||
1 | import { makePutBodyRequest } from '../requests/requests' | 1 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
2 | 2 | ||
3 | function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number) { | 3 | function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) { |
4 | const path = '/api/v1/videos/' + videoId + '/watching' | 4 | const path = '/api/v1/videos/' + videoId + '/watching' |
5 | const fields = { currentTime } | 5 | const fields = { currentTime } |
6 | 6 | ||
7 | return makePutBodyRequest({ url, path, token, fields, statusCodeExpected: 204 }) | 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 | }) | ||
8 | } | 31 | } |
9 | 32 | ||
10 | // --------------------------------------------------------------------------- | 33 | // --------------------------------------------------------------------------- |
11 | 34 | ||
12 | export { | 35 | export { |
13 | userWatchVideo | 36 | userWatchVideo, |
37 | listMyVideosHistory, | ||
38 | removeMyVideosHistory | ||
14 | } | 39 | } |