]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/server-commands/videos/history-command.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / server-commands / videos / history-command.ts
CommitLineData
4c7e60bc 1import { HttpStatusCode, ResultList, Video } from '@shared/models'
313228e9
C
2import { AbstractCommand, OverrideCommandOptions } from '../shared'
3
4export class HistoryCommand extends AbstractCommand {
5
313228e9
C
6 list (options: OverrideCommandOptions & {
7 search?: string
8 } = {}) {
9 const { search } = options
10 const path = '/api/v1/users/me/history/videos'
11
12 return this.getRequestBody<ResultList<Video>>({
13 ...options,
14
15 path,
16 query: {
17 search
18 },
19 implicitToken: true,
20 defaultExpectedStatus: HttpStatusCode.OK_200
21 })
22 }
23
7177b46c
C
24 removeElement (options: OverrideCommandOptions & {
25 videoId: number
26 }) {
27 const { videoId } = options
28 const path = '/api/v1/users/me/history/videos/' + videoId
29
30 return this.deleteRequest({
31 ...options,
32
33 path,
34 implicitToken: true,
35 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
36 })
37 }
38
39 removeAll (options: OverrideCommandOptions & {
313228e9
C
40 beforeDate?: string
41 } = {}) {
42 const { beforeDate } = options
43 const path = '/api/v1/users/me/history/videos/remove'
44
45 return this.postBodyRequest({
46 ...options,
47
48 path,
49 fields: { beforeDate },
50 implicitToken: true,
51 defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
52 })
53 }
54}