Add URL in search index

This commit is contained in:
Chocobozzz 2020-06-05 11:19:50 +02:00
parent fdbf6ede5f
commit dd765cecbf
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 9 additions and 1 deletions

View File

@ -1,12 +1,15 @@
import * as Bluebird from 'bluebird'
import * as request from 'request'
import { waitMs } from './core-utils'
import { CONFIG } from 'server/initializers/constants'
function doRequest <T> (
requestOptions: request.CoreOptions & request.UriOptions
): Bluebird<{ response: request.RequestResponse, body: T }> {
if (!(requestOptions.headers)) requestOptions.headers = {}
requestOptions.headers['User-Agent'] = 'PeerTube indexer'
const webserverUrl = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT
requestOptions.headers['User-Agent'] = `PeerTube search index (+${webserverUrl})`
return new Bluebird<{ response: request.RequestResponse, body: T }>((res, rej) => {
request(requestOptions, (err, response, body) => err ? rej(err) : res({ response, body }))

View File

@ -7,6 +7,11 @@ const CONFIG = {
LISTEN: {
PORT: config.get<number>('listen.port')
},
WEBSERVER: {
SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http',
HOSTNAME: config.get<string>('webserver.hostname'),
PORT: config.get<number>('webserver.port')
},
ELASTIC_SEARCH: {
HOSTNAME: config.get<string>('elastic_search.hostname'),
PORT: config.get<number>('elastic_search.port'),