]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/extra-utils/videos/video-history.ts
show first decimal for views above a thousand (#3564)
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / videos / video-history.ts
1 import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
2 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
3
4 function userWatchVideo (
5 url: string,
6 token: string,
7 videoId: number | string,
8 currentTime: number,
9 statusCodeExpected = HttpStatusCode.NO_CONTENT_204
10 ) {
11 const path = '/api/v1/videos/' + videoId + '/watching'
12 const fields = { currentTime }
13
14 return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
15 }
16
17 function listMyVideosHistory (url: string, token: string) {
18 const path = '/api/v1/users/me/history/videos'
19
20 return makeGetRequest({
21 url,
22 path,
23 token,
24 statusCodeExpected: HttpStatusCode.OK_200
25 })
26 }
27
28 function removeMyVideosHistory (url: string, token: string, beforeDate?: string) {
29 const path = '/api/v1/users/me/history/videos/remove'
30
31 return makePostBodyRequest({
32 url,
33 path,
34 token,
35 fields: beforeDate ? { beforeDate } : {},
36 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
37 })
38 }
39
40 // ---------------------------------------------------------------------------
41
42 export {
43 userWatchVideo,
44 listMyVideosHistory,
45 removeMyVideosHistory
46 }