diff --git a/CHANGELOG.md b/CHANGELOG.md
index b19157e8..45ba6ac7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ TODO: tag custom ConverseJS, and update build-conversejs.sh.
* #177: streamer's task/to-do lists: streamers, and their room's moderators, can handle task lists directly. This can be used to handle viewers questions, moderation actions, ... More info in the [tasks documentation](https://livingston.frama.io/peertube-plugin-livechat/fr/documentation/user/streamers/tasks/).
* #385: new way of managing chat access rights. Now streamers are owner of their chat rooms. Peertube admins/moderators are not by default, so that their identities are not leaking. But they have a button to promote as chat room owner, if they need to take action. Please note that there is a migration script that will remove all Peertube admins/moderators affiliations (unless they are video/channel's owner). They can get this access back using the button.
+* #385: the slow mode duration on the channel option page is now a default value for new rooms. Streamers can change the value room per room in the room's configuration.
### Minor changes and fixes
diff --git a/languages/en.yml b/languages/en.yml
index 7c5f924f..49010469 100644
--- a/languages/en.yml
+++ b/languages/en.yml
@@ -365,7 +365,7 @@ livechat_configuration_channel_title: "Channel options"
livechat_configuration_channel_desc: "You can setup here some options for this channel (moderation policies, ...)."
livechat_configuration_channel_slow_mode_label: "Slow mode"
livechat_configuration_channel_slow_mode_desc: |
- Slow mode value:
+ Slow mode default value:
- 0: slow mode disabled
- Any positive integer: users can send a message every X seconds (moderators are not limited)
diff --git a/languages/fr.yml b/languages/fr.yml
index 250bae8c..1878fd5e 100644
--- a/languages/fr.yml
+++ b/languages/fr.yml
@@ -393,7 +393,7 @@ avatar_set_option_abstract: Abstrait
livechat_configuration_channel_slow_mode_label: Mode lent
slow_mode_info: Le mode lent est activé, les utilisateur⋅rices peuvent envoyer un
message toutes les %1$s secondes.
-livechat_configuration_channel_slow_mode_desc: "Valeur du mode lent :\n\n - 0 :
+livechat_configuration_channel_slow_mode_desc: "Valeur par défaut du mode lent :\n
\n - 0 :
mode lent désactivé
\n - Tout entier positif : les utilisateur⋅rices peuvent
envoyer un message toutes les X secondes (les modérateur⋅rices ne sont pas limité⋅es)
\n\
\n"
diff --git a/server/lib/configuration/channel/init.ts b/server/lib/configuration/channel/init.ts
index 2dcc1d07..7e165619 100644
--- a/server/lib/configuration/channel/init.ts
+++ b/server/lib/configuration/channel/init.ts
@@ -4,7 +4,6 @@ import { fillVideoCustomFields } from '../../custom-fields'
import { videoHasWebchat } from '../../../../shared/lib/video'
import { updateProsodyRoom } from '../../prosody/api/manage-rooms'
import { getChannelInfosById } from '../../database/channel'
-import { getChannelConfigurationOptions, getDefaultChannelConfigurationOptions } from './storage'
/**
* Register stuffs related to channel configuration
@@ -107,11 +106,8 @@ async function initChannelConfiguration (options: RegisterServerOptions): Promis
// FIXME: this piece of code should not be in this file (nothing to do with initChannelConfiguration,
// but will be more efficient to add here, as we already tested hasChat).
// Note: no need to await here, would only degrade performances.
- const channelOptions = await getChannelConfigurationOptions(options, video.channelId) ??
- getDefaultChannelConfigurationOptions(options)
updateProsodyRoom(options, video.uuid, {
- name: video.name,
- slow_mode_duration: channelOptions.slowMode.duration
+ name: video.name
}).then(
() => {},
(err) => logger.error(err)
@@ -137,11 +133,8 @@ async function initChannelConfiguration (options: RegisterServerOptions): Promis
if (settings['prosody-room-type'] === 'channel') {
const jid = 'channel.' + channel.id.toString()
// Note: no need to await here, would only degrade performances.
- const channelOptions = await getChannelConfigurationOptions(options, channel.id) ??
- getDefaultChannelConfigurationOptions(options)
updateProsodyRoom(options, jid, {
- name: channel.displayName,
- slow_mode_duration: channelOptions.slowMode.duration
+ name: channel.displayName
}).then(
() => {},
(err) => logger.error(err)
diff --git a/server/lib/room-channel/room-channel-class.ts b/server/lib/room-channel/room-channel-class.ts
index b1fe14b7..6e5320ae 100644
--- a/server/lib/room-channel/room-channel-class.ts
+++ b/server/lib/room-channel/room-channel-class.ts
@@ -1,7 +1,7 @@
import type { RegisterServerOptions } from '@peertube/peertube-types'
import type { RoomConf } from 'xmppjs-chat-bot'
import { getProsodyDomain } from '../prosody/config/domain'
-import { listProsodyRooms, updateProsodyRoom } from '../prosody/api/manage-rooms'
+import { listProsodyRooms } from '../prosody/api/manage-rooms'
import { getChannelInfosById } from '../database/channel'
import { ChannelConfigurationOptions } from '../../../shared/lib/types'
import {
@@ -288,7 +288,10 @@ class RoomChannel {
this.logger.info('Syncing...')
this.isWriting = true
- const prosodyRoomUpdates = new Map[2]>()
+ // Note 2024-05-15: slow_mode_duration becomes a default value.
+ // We dont need prosodyRoomUpdates anymore. but keeping the code commented,
+ // if we want to enable again a similar sync.
+ // const prosodyRoomUpdates = new Map[2]>()
try {
const data = this._serializeData() // must be atomic
@@ -348,12 +351,12 @@ class RoomChannel {
await BotConfiguration.singleton().updateRoom(roomJID, botConf)
- // Now we also must update some room metadata (slow mode duration, ...)
- // This can be done without waiting for the API call to finish, but we don't want to send thousands of
- // API calls at the same time. So storing data in a map, and we well launch it sequentially at the end
- prosodyRoomUpdates.set(roomJID, {
- slow_mode_duration: channelConfigurationOptions.slowMode.duration
- })
+ // // Now we also must update some room metadata (slow mode duration, ...)
+ // // This can be done without waiting for the API call to finish, but we don't want to send thousands of
+ // // API calls at the same time. So storing data in a map, and we well launch it sequentially at the end
+ // prosodyRoomUpdates.set(roomJID, {
+ // slow_mode_duration: channelConfigurationOptions.slowMode.duration
+ // })
this.roomConfToUpdate.delete(roomJID)
}
@@ -367,22 +370,22 @@ class RoomChannel {
this.isWriting = false
}
- if (prosodyRoomUpdates.size) {
- // Here we don't have to wait.
- // If it fails (for example because we are turning off prosody), it is not a big deal.
- // Does not worth the cost to wait.
- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- setTimeout(async () => {
- this.logger.info('Syncing done, but still some data to send to Prosody')
- for (const [roomJID, data] of prosodyRoomUpdates.entries()) {
- try {
- await updateProsodyRoom(this.options, roomJID, data)
- } catch (err) {
- this.logger.error(`Failed updating prosody room info: "${err as string}".`)
- }
- }
- }, 0)
- }
+ // if (prosodyRoomUpdates.size) {
+ // // Here we don't have to wait.
+ // // If it fails (for example because we are turning off prosody), it is not a big deal.
+ // // Does not worth the cost to wait.
+ // // eslint-disable-next-line @typescript-eslint/no-misused-promises
+ // setTimeout(async () => {
+ // this.logger.info('Syncing done, but still some data to send to Prosody')
+ // for (const [roomJID, data] of prosodyRoomUpdates.entries()) {
+ // try {
+ // await updateProsodyRoom(this.options, roomJID, data)
+ // } catch (err) {
+ // this.logger.error(`Failed updating prosody room info: "${err as string}".`)
+ // }
+ // }
+ // }, 0)
+ // }
}
/**