]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/utils/videos/video-history.ts
Refractor published date on video import
[github/Chocobozzz/PeerTube.git] / shared / utils / videos / video-history.ts
CommitLineData
8b9a525a 1import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
6e46de09 2
8b9a525a 3function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) {
6e46de09
C
4 const path = '/api/v1/videos/' + videoId + '/watching'
5 const fields = { currentTime }
6
8b9a525a
C
7 return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
8}
9
10function 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
21function 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 })
6e46de09
C
31}
32
33// ---------------------------------------------------------------------------
34
35export {
8b9a525a
C
36 userWatchVideo,
37 listMyVideosHistory,
38 removeMyVideosHistory
6e46de09 39}