1
0
Fork 0
peertube/shared/extra-utils/videos/video-history.ts
Rigel Kent d8b34ee55b
Allow user to search through their watch history (#3576)
* allow user to search through their watch history

* add tests for search in watch history

* Update client/src/app/shared/shared-main/users/user-history.service.ts
2021-01-13 09:16:15 +01:00

49 lines
1.2 KiB
TypeScript

import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
function userWatchVideo (
url: string,
token: string,
videoId: number | string,
currentTime: number,
statusCodeExpected = HttpStatusCode.NO_CONTENT_204
) {
const path = '/api/v1/videos/' + videoId + '/watching'
const fields = { currentTime }
return makePutBodyRequest({ url, path, token, fields, statusCodeExpected })
}
function listMyVideosHistory (url: string, token: string, search?: string) {
const path = '/api/v1/users/me/history/videos'
return makeGetRequest({
url,
path,
token,
query: {
search
},
statusCodeExpected: HttpStatusCode.OK_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: HttpStatusCode.NO_CONTENT_204
})
}
// ---------------------------------------------------------------------------
export {
userWatchVideo,
listMyVideosHistory,
removeMyVideosHistory
}