From 260a25f4113ff0acaf42fde125afd1be44aa28b5 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Mon, 18 Sep 2023 15:05:21 +0200 Subject: [PATCH] Updating room-channel when prosody-room-type is changed --- server/lib/settings.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 16ccfc86..3de762b7 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -1,6 +1,7 @@ import type { RegisterServerOptions } from '@peertube/peertube-types' -import { ensureProsodyRunning } from './prosody/ctl' import type { ConverseJSTheme } from '../../shared/lib/types' +import { ensureProsodyRunning } from './prosody/ctl' +import { RoomChannel } from './room-channel' import { loc } from './loc' async function initSettings (options: RegisterServerOptions): Promise { @@ -396,10 +397,22 @@ Please read descriptionHTML: loc('prosody_components_list_description') }) + let currentProsodyRoomtype = (await settingsManager.getSettings(['prosody-room-type']))['prosody-room-type'] + // ********** settings changes management - settingsManager.onSettingsChange(async (_settings: any) => { + settingsManager.onSettingsChange(async (settings: any) => { peertubeHelpers.logger.info('Saving settings, ensuring prosody is running') await ensureProsodyRunning(options) + // In case prosody-room-type changed, we must rebuild room-channel links. + if (settings['prosody-room-type'] !== currentProsodyRoomtype) { + peertubeHelpers.logger.info('Setting prosody-room-type has changed value, must rebuild room-channel infos') + // doing it without waiting, could be long! + RoomChannel.singleton().rebuildData().then( + () => peertubeHelpers.logger.info('Room-channel info rebuild ok.'), + (err) => peertubeHelpers.logger.error(err) + ) + } + currentProsodyRoomtype = settings['prosody-room-type'] }) }