Slow mode (related to #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.
This commit is contained in:
parent
da75765bdb
commit
4afc6ec4c6
@ -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
|
||||
|
||||
|
@ -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:
|
||||
<ul>
|
||||
<li>0: slow mode disabled</li>
|
||||
<li>Any positive integer: users can send a message every X seconds (moderators are not limited)</li>
|
||||
|
@ -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<ul>\n <li>0 :
|
||||
livechat_configuration_channel_slow_mode_desc: "Valeur par défaut du mode lent :\n<ul>\n <li>0 :
|
||||
mode lent désactivé</li>\n <li>Tout entier positif : les utilisateur⋅rices peuvent
|
||||
envoyer un message toutes les X secondes (les modérateur⋅rices ne sont pas limité⋅es)</li>\n\
|
||||
</ul>\n"
|
||||
|
@ -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)
|
||||
|
@ -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<string, Parameters<typeof updateProsodyRoom>[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<string, Parameters<typeof updateProsodyRoom>[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)
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user