Builtin Prosody: optional settings to change the url for Prosody's API calls.
This commit is contained in:
parent
a526feac19
commit
6608480826
@ -4,6 +4,7 @@
|
||||
|
||||
### Features
|
||||
|
||||
* Builtin Prosody: optional settings to change the url for Prosody's API calls.
|
||||
* Diagnostic tool: testing API communication from Peertube to Prosody.
|
||||
* Diagnostic tool: testing API communication from Prosody to Peertube.
|
||||
|
||||
|
@ -40,6 +40,7 @@ function register ({ registerHook, registerSettingsScript, peertubeHelpers }: Re
|
||||
case 'chat-type-help-disabled':
|
||||
return options.formValues['chat-type'] !== ('disabled' as ChatType)
|
||||
case 'prosody-port':
|
||||
case 'prosody-peertube-uri':
|
||||
case 'chat-type-help-builtin-prosody':
|
||||
return options.formValues['chat-type'] !== ('builtin-prosody' as ChatType)
|
||||
case 'chat-server':
|
||||
|
@ -28,6 +28,8 @@ export async function diagProsody (test: string, options: RegisterServerOptions)
|
||||
result.messages.push(`Prosody will run on port '${wantedConfig.port}'`)
|
||||
prosodyPort = wantedConfig.port
|
||||
|
||||
result.messages.push(`Prosody will use ${wantedConfig.baseApiUrl} as base uri from api calls`)
|
||||
|
||||
result.messages.push(`Prosody modules path will be '${wantedConfig.paths.modules}'`)
|
||||
|
||||
await fs.promises.access(filePath, fs.constants.R_OK) // throw an error if file does not exist.
|
||||
|
@ -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,9 +81,15 @@ 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
|
||||
@ -118,7 +125,8 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
|
||||
return {
|
||||
content,
|
||||
paths,
|
||||
port
|
||||
port,
|
||||
baseApiUrl
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,6 +103,18 @@ Change it if this port is already in use on your server.<br>
|
||||
You can close this port on your firewall, it will not be accessed from the outer world.`
|
||||
})
|
||||
|
||||
registerSetting({
|
||||
name: 'prosody-peertube-uri',
|
||||
label: 'Peertube url for API calls',
|
||||
type: 'input',
|
||||
default: '',
|
||||
private: true,
|
||||
descriptionHTML:
|
||||
`Please let this settings empty if you don't know what you are doing.<br>
|
||||
In some rare case, Prosody can't call Peertube's API from its public URI.
|
||||
You can use this field to customise Peertube's URI for Prosody modules (for example with «http://localhost:9000»).`
|
||||
})
|
||||
|
||||
registerSetting({
|
||||
name: 'chat-server',
|
||||
label: 'XMPP service server',
|
||||
|
Loading…
x
Reference in New Issue
Block a user