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