WIP on Prosody integration.

This commit is contained in:
John Livingston
2021-04-13 17:13:41 +02:00
parent 4690d97384
commit cc21305f6a
5 changed files with 164 additions and 22 deletions

View File

@ -1,8 +1,9 @@
import { getBaseRouter } from './helpers'
import { ensureProsodyRunning, ensureProsodyNotRunning } from './prosody/ctl'
export function initSettings (options: RegisterServerOptions): void {
const { peertubeHelpers, registerSetting, settingsManager } = options
export function initSettings ({
registerSetting
}: RegisterServerOptions): void {
registerSetting({
name: 'chat-read-documentation',
label: 'I have read the documentation',
@ -157,4 +158,20 @@ export function initSettings ({
'Example: height:400px;',
private: false
})
// settings changes management
// FIXME: Peertube <= 3.1.0 wrongly consider that the callback should not be async
// eslint-disable-next-line @typescript-eslint/no-misused-promises
settingsManager.onSettingsChange(async (settings: any) => {
if ('chat-use-prosody' in settings) {
if (settings['chat-use-prosody'] === true) {
peertubeHelpers.logger.info('Saving settings, ensuring prosody is running')
await ensureProsodyRunning(options)
} else if (settings['chat-use-prody'] === false) {
peertubeHelpers.logger.info('Saving settings, ensuring prosody is not running')
await ensureProsodyNotRunning(options)
}
}
})
}