]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/query.ts
Add ability to filter by file type
[github/Chocobozzz/PeerTube.git] / server / helpers / query.ts
CommitLineData
d6886027
C
1import { pick } from '@shared/core-utils'
2import {
3 VideoChannelsSearchQueryAfterSanitize,
4 VideoPlaylistsSearchQueryAfterSanitize,
5 VideosCommonQueryAfterSanitize,
6 VideosSearchQueryAfterSanitize
7} from '@shared/models'
8
9function pickCommonVideoQuery (query: VideosCommonQueryAfterSanitize) {
10 return pick(query, [
11 'start',
12 'count',
13 'sort',
14 'nsfw',
15 'isLive',
16 'categoryOneOf',
17 'licenceOneOf',
18 'languageOneOf',
19 'tagsOneOf',
20 'tagsAllOf',
2760b454
C
21 'isLocal',
22 'include',
23 'skipCount',
d324756e
C
24 'hasHLSFiles',
25 'hasWebtorrentFiles',
2760b454 26 'search'
d6886027
C
27 ])
28}
29
30function pickSearchVideoQuery (query: VideosSearchQueryAfterSanitize) {
31 return {
32 ...pickCommonVideoQuery(query),
33
34 ...pick(query, [
35 'searchTarget',
d6886027
C
36 'host',
37 'startDate',
38 'endDate',
39 'originallyPublishedStartDate',
40 'originallyPublishedEndDate',
41 'durationMin',
42 'durationMax',
43 'uuids'
44 ])
45 }
46}
47
48function pickSearchChannelQuery (query: VideoChannelsSearchQueryAfterSanitize) {
49 return pick(query, [
50 'searchTarget',
51 'search',
52 'start',
53 'count',
54 'sort',
55 'host',
56 'handles'
57 ])
58}
59
60function pickSearchPlaylistQuery (query: VideoPlaylistsSearchQueryAfterSanitize) {
61 return pick(query, [
62 'searchTarget',
63 'search',
64 'start',
65 'count',
66 'sort',
67 'host',
68 'uuids'
69 ])
70}
71
72export {
73 pickCommonVideoQuery,
74 pickSearchVideoQuery,
75 pickSearchPlaylistQuery,
76 pickSearchChannelQuery
77}