PeerTube/shared/utils/videos/video-history.ts

40 lines
1.0 KiB
TypeScript
Raw Normal View History

import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
2018-10-05 04:15:06 -05:00
function userWatchVideo (url: string, token: string, videoId: number | string, currentTime: number, statusCodeExpected = 204) {
2018-10-05 04:15:06 -05:00
const path = '/api/v1/videos/' + videoId + '/watching'
const fields = { currentTime }
return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
}
function listMyVideosHistory (url: string, token: string) {
const path = '/api/v1/users/me/history/videos'
return makeGetRequest({
url,
path,
token,
statusCodeExpected: 200
})
}
function removeMyVideosHistory (url: string, token: string, beforeDate?: string) {
const path = '/api/v1/users/me/history/videos/remove'
return makePostBodyRequest({
url,
path,
token,
fields: beforeDate ? { beforeDate } : {},
statusCodeExpected: 204
})
2018-10-05 04:15:06 -05:00
}
// ---------------------------------------------------------------------------
export {
userWatchVideo,
listMyVideosHistory,
removeMyVideosHistory
2018-10-05 04:15:06 -05:00
}