Merge branch 'release/3.2.0' into prosody_room_list

This commit is contained in:
John Livingston
2021-06-22 13:47:39 +02:00
12 changed files with 208 additions and 10 deletions

View File

@ -67,6 +67,7 @@ interface ProsodyConfig {
content: string
paths: ProsodyFilePaths
port: string
baseApiUrl: string
}
async function getProsodyConfig (options: RegisterServerOptions): Promise<ProsodyConfig> {
const logger = options.peertubeHelpers.logger
@ -80,11 +81,18 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
const paths = await getProsodyFilePaths(options)
const apikey = await getAPIKey(options)
const baseApiUrl = options.peertubeHelpers.config.getWebserverUrl() +
getBaseRouterRoute(options) +
'api/'
let baseApiUrl = await options.settingsManager.getSetting('prosody-peertube-uri') as string
if (baseApiUrl && !/^https?:\/\/[a-z0-9.-_]+(?::\d+)?$/.test(baseApiUrl)) {
throw new Error('Invalid prosody-peertube-uri')
}
if (!baseApiUrl) {
baseApiUrl = options.peertubeHelpers.config.getWebserverUrl()
}
baseApiUrl += getBaseRouterRoute(options) + 'api/'
const authApiUrl = baseApiUrl + 'user' // FIXME: should be protected by apikey, but mod_auth_http cant handle params
const roomApiUrl = baseApiUrl + 'room?apikey=' + apikey + '&jid={room.jid|jid_node}'
const testApiUrl = baseApiUrl + 'test?apikey=' + apikey
const config = new ProsodyConfigContent(paths, prosodyDomain)
config.useHttpAuthentication(authApiUrl)
@ -98,6 +106,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
config.useListRoomsApi(apikey)
config.useTestModule(apikey, testApiUrl)
let logLevel: ProsodyLogLevel | undefined
if (logger.level && (typeof logger.level === 'string')) {
if (logger.level === 'error' || logger.level === 'info' || logger.level === 'debug') {
@ -117,7 +127,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
return {
content,
paths,
port
port,
baseApiUrl
}
}

View File

@ -241,6 +241,12 @@ class ProsodyConfigContent {
this.muc.set('peertubelivechat_list_rooms_apikey', apikey)
}
useTestModule (prosodyApikey: string, apiurl: string): void {
this.global.add('modules_enabled', 'http_peertubelivechat_test')
this.global.set('peertubelivechat_test_apikey', prosodyApikey)
this.global.set('peertubelivechat_test_peertube_api_url', apiurl)
}
setLog (level: ProsodyLogLevel, syslog?: ProsodyLogLevel[]): void {
let log = ''
log += 'log = {\n'