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