]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/helpers/query.ts
Use different p2p policy for embeds and webapp
[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',
527a52ac 19 'privacyOneOf',
d6886027
C
20 'tagsOneOf',
21 'tagsAllOf',
2760b454
C
22 'isLocal',
23 'include',
24 'skipCount',
d324756e
C
25 'hasHLSFiles',
26 'hasWebtorrentFiles',
2760b454 27 'search'
d6886027
C
28 ])
29}
30
31function pickSearchVideoQuery (query: VideosSearchQueryAfterSanitize) {
32 return {
33 ...pickCommonVideoQuery(query),
34
35 ...pick(query, [
36 'searchTarget',
d6886027
C
37 'host',
38 'startDate',
39 'endDate',
40 'originallyPublishedStartDate',
41 'originallyPublishedEndDate',
42 'durationMin',
43 'durationMax',
44 'uuids'
45 ])
46 }
47}
48
49function pickSearchChannelQuery (query: VideoChannelsSearchQueryAfterSanitize) {
50 return pick(query, [
51 'searchTarget',
52 'search',
53 'start',
54 'count',
55 'sort',
56 'host',
57 'handles'
58 ])
59}
60
61function pickSearchPlaylistQuery (query: VideoPlaylistsSearchQueryAfterSanitize) {
62 return pick(query, [
63 'searchTarget',
64 'search',
65 'start',
66 'count',
67 'sort',
68 'host',
69 'uuids'
70 ])
71}
72
73export {
74 pickCommonVideoQuery,
75 pickSearchVideoQuery,
76 pickSearchPlaylistQuery,
77 pickSearchChannelQuery
78}