aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-29 16:16:24 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-10 14:02:41 +0200
commit5fb2e2888ce032c638e4b75d07458642f0833e52 (patch)
tree8830d873569316889b8134027e9a43b198cca38f /server/initializers
parent62e7be634bc189f942ae51cb4b080079ab503ff0 (diff)
downloadPeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.gz
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.zst
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.zip
First implem global search
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-after-init.ts7
-rw-r--r--server/initializers/checker-before-init.ts4
-rw-r--r--server/initializers/config.ts18
-rw-r--r--server/initializers/constants.ts11
4 files changed, 33 insertions, 7 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index b5b854137..b49ab6bca 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -128,6 +128,13 @@ function checkConfig () {
128 } 128 }
129 } 129 }
130 130
131 // Search index
132 if (CONFIG.SEARCH.SEARCH_INDEX.ENABLED === true) {
133 if (CONFIG.SEARCH.REMOTE_URI.USERS === false) {
134 return 'You cannot enable search index without enabling remote URI search for users.'
135 }
136 }
137
131 return null 138 return null
132} 139}
133 140
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index bd8f02bc0..e0819c4aa 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -35,7 +35,9 @@ function checkMissedConfig () {
35 'rates_limit.login.window', 'rates_limit.login.max', 'rates_limit.ask_send_email.window', 'rates_limit.ask_send_email.max', 35 'rates_limit.login.window', 'rates_limit.login.max', 'rates_limit.ask_send_email.window', 'rates_limit.ask_send_email.max',
36 'theme.default', 36 'theme.default',
37 'remote_redundancy.videos.accept_from', 37 'remote_redundancy.videos.accept_from',
38 'federation.videos.federate_unlisted' 38 'federation.videos.federate_unlisted',
39 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url',
40 'search.search_index.disable_local_search', 'search.search_index.is_default_search'
39 ] 41 ]
40 const requiredAlternatives = [ 42 const requiredAlternatives = [
41 [ // set 43 [ // set
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 44fd9045b..5b402dd74 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -104,12 +104,6 @@ const CONFIG = {
104 }, 104 },
105 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP') 105 ANONYMIZE_IP: config.get<boolean>('log.anonymizeIP')
106 }, 106 },
107 SEARCH: {
108 REMOTE_URI: {
109 USERS: config.get<boolean>('search.remote_uri.users'),
110 ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous')
111 }
112 },
113 TRENDING: { 107 TRENDING: {
114 VIDEOS: { 108 VIDEOS: {
115 INTERVAL_DAYS: config.get<number>('trending.videos.interval_days') 109 INTERVAL_DAYS: config.get<number>('trending.videos.interval_days')
@@ -297,6 +291,18 @@ const CONFIG = {
297 get MESSAGE () { return config.get<string>('broadcast_message.message') }, 291 get MESSAGE () { return config.get<string>('broadcast_message.message') },
298 get LEVEL () { return config.get<BroadcastMessageLevel>('broadcast_message.level') }, 292 get LEVEL () { return config.get<BroadcastMessageLevel>('broadcast_message.level') },
299 get DISMISSABLE () { return config.get<boolean>('broadcast_message.dismissable') } 293 get DISMISSABLE () { return config.get<boolean>('broadcast_message.dismissable') }
294 },
295 SEARCH: {
296 REMOTE_URI: {
297 USERS: config.get<boolean>('search.remote_uri.users'),
298 ANONYMOUS: config.get<boolean>('search.remote_uri.anonymous')
299 },
300 SEARCH_INDEX: {
301 get ENABLED () { return config.get<boolean>('search.search_index.enabled') },
302 get URL () { return config.get<string>('search.search_index.url') },
303 get DISABLE_LOCAL_SEARCH () { return config.get<boolean>('search.search_index.disable_local_search') },
304 get IS_DEFAULT_SEARCH () { return config.get<boolean>('search.search_index.is_default_search') }
305 }
300 } 306 }
301} 307}
302 308
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index d201df3d8..314f094b3 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -61,6 +61,7 @@ const SORTABLE_COLUMNS = {
61 61
62 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending' ], 62 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending' ],
63 63
64 // Don't forget to update peertube-search-index with the same values
64 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'match' ], 65 VIDEOS_SEARCH: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'match' ],
65 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ], 66 VIDEO_CHANNELS_SEARCH: [ 'match', 'displayName', 'createdAt' ],
66 67
@@ -649,6 +650,15 @@ const DEFAULT_USER_THEME_NAME = 'instance-default'
649 650
650// --------------------------------------------------------------------------- 651// ---------------------------------------------------------------------------
651 652
653const SEARCH_INDEX = {
654 ROUTES: {
655 VIDEOS: '/api/v1/search/videos',
656 VIDEO_CHANNELS: '/api/v1/search/video-channels'
657 }
658}
659
660// ---------------------------------------------------------------------------
661
652// Special constants for a test instance 662// Special constants for a test instance
653if (isTestInstance() === true) { 663if (isTestInstance() === true) {
654 PRIVATE_RSA_KEY_SIZE = 1024 664 PRIVATE_RSA_KEY_SIZE = 1024
@@ -704,6 +714,7 @@ export {
704 API_VERSION, 714 API_VERSION,
705 PEERTUBE_VERSION, 715 PEERTUBE_VERSION,
706 LAZY_STATIC_PATHS, 716 LAZY_STATIC_PATHS,
717 SEARCH_INDEX,
707 HLS_REDUNDANCY_DIRECTORY, 718 HLS_REDUNDANCY_DIRECTORY,
708 P2P_MEDIA_LOADER_PEER_VERSION, 719 P2P_MEDIA_LOADER_PEER_VERSION,
709 AVATARS_SIZE, 720 AVATARS_SIZE,