Builtin Prosody: BOSH path without plugin version, so it can be optimized in the nginx configuration.

This commit is contained in:
John Livingston 2022-08-23 18:53:12 +02:00
parent 7906ddf625
commit 7259ae59a2
No known key found for this signature in database
GPG Key ID: B17B5640CE66CDBC
3 changed files with 16 additions and 3 deletions

View File

@ -23,7 +23,9 @@ If you don't want the chat server to be active, just uninstall the plugin
### New Features
*
* Removed deprecated modes, only keeping «Prosody server controlled by Peertube».
* BOSH proxy optimization + enabling websocket.
* BOSH path without plugin version, so it can be optimized in the nginx configuration.
## 5.7.1

View File

@ -19,6 +19,16 @@ function getBaseRouterRoute (options: RegisterServerOptions): string {
return options.peertubeHelpers.plugin.getBaseRouterRoute()
}
/**
* Returns the base router route, but without the plugin version.
* @param options server options
*/
function getBaseRouterCanonicalRoute (options: RegisterServerOptions): string {
let route = getBaseRouterRoute(options)
route = route.replace(pluginShortName + '/' + version + '/', pluginShortName + '/')
return route
}
function getBaseStaticRoute (options: RegisterServerOptions): string {
if (!options.peertubeHelpers.plugin) {
throw new Error('Missing peertubeHelpers.plugin, have you the correct Peertube version?')
@ -62,6 +72,7 @@ async function getUserNickname (options: RegisterServerOptions, user: AuthUserFi
export {
getBaseRouterRoute,
getBaseRouterCanonicalRoute,
getBaseStaticRoute,
isUserAdmin,
getUserNickname,

View File

@ -4,7 +4,7 @@ import type { ProxyOptions } from 'express-http-proxy'
import type {
ProsodyListRoomsResult, ProsodyListRoomsResultRoom
} from '../../../shared/lib/types'
import { getBaseRouterRoute, getBaseStaticRoute, isUserAdmin } from '../helpers'
import { getBaseRouterRoute, getBaseRouterCanonicalRoute, getBaseStaticRoute, isUserAdmin } from '../helpers'
import { asyncMiddleware } from '../middlewares/async'
import { getProsodyDomain } from '../prosody/config/domain'
import { getAPIKey } from '../apikey'
@ -76,7 +76,7 @@ async function initWebchatRouter (options: RegisterServerOptions): Promise<Route
room = '{{VIDEO_UUID}}@room.' + prosodyDomain
}
}
const boshUri = getBaseRouterRoute(options) + 'webchat/http-bind'
const boshUri = getBaseRouterCanonicalRoute(options) + 'webchat/http-bind'
const wsUri = ''
authenticationUrl = options.peertubeHelpers.config.getWebserverUrl() +
getBaseRouterRoute(options) +