]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/videos/video-history.ts
replace numbers with typed http status codes (#3409)
[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
8b9a525a 4function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) {
6e46de09
C
5 const path = '/api/v1/videos/' + videoId + '/watching'
6 const fields = { currentTime }
7
8b9a525a
C
8 return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
9}
10
11function listMyVideosHistory (url: string, token: string) {
12 const path = '/api/v1/users/me/history/videos'
13
14 return makeGetRequest({
15 url,
16 path,
17 token,
2d53be02 18 statusCodeExpected: HttpStatusCode.OK_200
8b9a525a
C
19 })
20}
21
22function removeMyVideosHistory (url: string, token: string, beforeDate?: string) {
23 const path = '/api/v1/users/me/history/videos/remove'
24
25 return makePostBodyRequest({
26 url,
27 path,
28 token,
29 fields: beforeDate ? { beforeDate } : {},
2d53be02 30 statusCodeExpected: HttpStatusCode.NO_CONTENT_204
8b9a525a 31 })
6e46de09
C
32}
33
34// ---------------------------------------------------------------------------
35
36export {
8b9a525a
C
37 userWatchVideo,
38 listMyVideosHistory,
39 removeMyVideosHistory
6e46de09 40}