1
0
Fork 0
peertube/shared/server-commands/videos/history-command.ts
Chocobozzz b211106695 Support video views/viewers stats in server
* Add "currentTime" and "event" body params to view endpoint
 * Merge watching and view endpoints
 * Introduce WatchAction AP activity
 * Add tables to store viewer information of local videos
 * Add endpoints to fetch video views/viewers stats of local videos
 * Refactor views/viewers handlers
 * Support "views" and "viewers" counters for both VOD and live videos
2022-04-15 09:49:35 +02:00

54 lines
1.2 KiB
TypeScript

import { HttpStatusCode, ResultList, Video } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class HistoryCommand extends AbstractCommand {
list (options: OverrideCommandOptions & {
search?: string
} = {}) {
const { search } = options
const path = '/api/v1/users/me/history/videos'
return this.getRequestBody<ResultList<Video>>({
...options,
path,
query: {
search
},
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
removeElement (options: OverrideCommandOptions & {
videoId: number
}) {
const { videoId } = options
const path = '/api/v1/users/me/history/videos/' + videoId
return this.deleteRequest({
...options,
path,
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
removeAll (options: OverrideCommandOptions & {
beforeDate?: string
} = {}) {
const { beforeDate } = options
const path = '/api/v1/users/me/history/videos/remove'
return this.postBodyRequest({
...options,
path,
fields: { beforeDate },
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
}