From e57d39c8aba2bcf32f77477e9c913ac333d37760 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Thu, 25 Jul 2024 12:09:55 +0200 Subject: [PATCH] Fix #481: * Moderation bot was not able to connect when remote chat was disabled. * Some cleaning in code generating Prosody configuration file. * Bump version 10.3.3 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- server/lib/prosody/config/content.ts | 13 ++++++++----- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 10407d93..352a3d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 10.3.3 + +### Minor changes and fixes + +* Fix #481: Moderation bot was not able to connect when remote chat was disabled. +* Some cleaning in code generating Prosody configuration file. + ## 10.3.2 ### Minor changes and fixes diff --git a/package-lock.json b/package-lock.json index 501b92e8..0f02b0db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "peertube-plugin-livechat", - "version": "10.3.2", + "version": "10.3.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "peertube-plugin-livechat", - "version": "10.3.2", + "version": "10.3.3", "license": "AGPL-3.0", "dependencies": { "@xmpp/jid": "^0.13.1", diff --git a/package.json b/package.json index 419b0db0..b90f9adb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "peertube-plugin-livechat", "description": "PeerTube plugin livechat: create chat rooms for your Peertube lives! Comes with many features: federation, moderation tools, chat bot, chat persistence, OBS integration, ...", - "version": "10.3.2", + "version": "10.3.3", "license": "AGPL-3.0", "author": { "name": "John Livingston", diff --git a/server/lib/prosody/config/content.ts b/server/lib/prosody/config/content.ts index a7423f75..fe2da987 100644 --- a/server/lib/prosody/config/content.ts +++ b/server/lib/prosody/config/content.ts @@ -93,7 +93,7 @@ abstract class ProsodyConfigBlock { this.entries.set(name, value) } - add (name: string, value: ConfigEntryValue): void { + add (name: string, value: ConfigEntryValue, allowDuplicate?: boolean): void { if (!this.entries.has(name)) { this.entries.set(name, []) } @@ -101,6 +101,9 @@ abstract class ProsodyConfigBlock { if (!Array.isArray(entry)) { entry = [entry] } + if (!allowDuplicate && entry.includes(value)) { + return + } entry.push(value) this.entries.set(name, entry) } @@ -239,7 +242,7 @@ class ProsodyConfigContent { this.muc.set('muc_room_default_history_length', 20) this.muc.add('modules_enabled', 'muc_slow_mode') - this.muc.add('slow_mode_duration_form_position', 120) + this.muc.set('slow_mode_duration_form_position', 120) this.muc.add('modules_enabled', 'pubsub_peertubelivechat') this.muc.add('modules_enabled', 'muc_peertubelivechat_roles') @@ -251,7 +254,7 @@ class ProsodyConfigContent { } this.muc.add('modules_enabled', 'muc_moderation_delay') - this.muc.add('moderation_delay_form_position', 118) + this.muc.set('moderation_delay_form_position', 118) } useAnonymous (autoBanIP: boolean): void { @@ -445,7 +448,7 @@ class ProsodyConfigContent { useMucHttpDefault (url: string): void { this.muc.add('modules_enabled', 'muc_http_defaults') - this.muc.add('muc_create_api_url', url) + this.muc.set('muc_create_api_url', url) // restrict_room_creation: we can override the 'local' value. // Indeed, when muc_http_default is used, room creation will be managed by api. @@ -517,7 +520,7 @@ class ProsodyConfigContent { */ useBotsVirtualHost (botAvatarPath: string, botAvatarFiles: string[]): void { this.bot = new ProsodyConfigVirtualHost('bot.' + this.prosodyDomain) - this.bot.set('modules_enabled', ['ping']) + this.bot.set('modules_enabled', ['ping', 'tls']) this.bot.set('authentication', 'peertubelivechat_bot') // For now, just using random_vcard_peertubelivechat to set bot avatar