New option to only allow registered users to speak WIP (#233):
* Prosody mod_muc_peertubelivechat_roles module * Fix ConverseJS to disable the message field when room is unmoderated and user is visitor * Mute/voice anonymous users when changing room configuration. * Display a specific message to muted anonymous users. * Default value for mute_anonymous in channel options. * Feature documentation
This commit is contained in:
@ -35,6 +35,14 @@ async function sanitizeChannelConfigurationOptions (
|
||||
throw new Error('Invalid data.slowMode data type')
|
||||
}
|
||||
|
||||
// mute not present in livechat <= 10.2.0
|
||||
const mute = data.mute ?? {}
|
||||
mute.anonymous ??= false
|
||||
|
||||
if (typeof mute !== 'object') {
|
||||
throw new Error('Invalid data.mute data type')
|
||||
}
|
||||
|
||||
const result: ChannelConfigurationOptions = {
|
||||
bot: {
|
||||
enabled: _readBoolean(botData, 'enabled'),
|
||||
@ -46,6 +54,9 @@ async function sanitizeChannelConfigurationOptions (
|
||||
},
|
||||
slowMode: {
|
||||
duration: _readInteger(slowModeData, 'duration', 0, 1000)
|
||||
},
|
||||
mute: {
|
||||
anonymous: _readBoolean(mute, 'anonymous')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,9 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
|
||||
},
|
||||
slowMode: {
|
||||
duration: 0
|
||||
},
|
||||
mute: {
|
||||
anonymous: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -213,6 +213,7 @@ class ProsodyConfigContent {
|
||||
|
||||
this.muc.add('modules_enabled', 'muc_slow_mode')
|
||||
this.muc.add('modules_enabled', 'pubsub_peertubelivechat')
|
||||
this.muc.add('modules_enabled', 'muc_peertubelivechat_roles')
|
||||
this.muc.add('slow_mode_duration_form_position', 120)
|
||||
}
|
||||
|
||||
|
@ -36,14 +36,22 @@ interface RoomDefaults {
|
||||
|
||||
// Following fields are specific to livechat (for now), and requires a customized version for mod_muc_http_defaults.
|
||||
slow_mode_duration?: number
|
||||
mute_anonymous?: boolean
|
||||
}
|
||||
affiliations?: Affiliations
|
||||
}
|
||||
|
||||
async function slowModeDuration (options: RegisterServerOptions, channelId: number): Promise<number> {
|
||||
async function _getChannelSpecificOptions (
|
||||
options: RegisterServerOptions,
|
||||
channelId: number
|
||||
): Promise<Partial<RoomDefaults['config']>> {
|
||||
const channelOptions = await getChannelConfigurationOptions(options, channelId) ??
|
||||
getDefaultChannelConfigurationOptions(options)
|
||||
return channelOptions.slowMode.duration
|
||||
|
||||
return {
|
||||
slow_mode_duration: channelOptions.slowMode.duration,
|
||||
mute_anonymous: channelOptions.mute.anonymous
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,12 +97,14 @@ async function initRoomApiRouter (options: RegisterServerOptions, router: Router
|
||||
}
|
||||
|
||||
const roomDefaults: RoomDefaults = {
|
||||
config: {
|
||||
name: channelInfos.displayName,
|
||||
description: '',
|
||||
// subject: channelInfos.displayName
|
||||
slow_mode_duration: await slowModeDuration(options, channelId)
|
||||
},
|
||||
config: Object.assign(
|
||||
{
|
||||
name: channelInfos.displayName,
|
||||
description: ''
|
||||
// subject: channelInfos.displayName
|
||||
},
|
||||
await _getChannelSpecificOptions(options, channelId)
|
||||
),
|
||||
affiliations: affiliations
|
||||
}
|
||||
|
||||
@ -141,13 +151,15 @@ async function initRoomApiRouter (options: RegisterServerOptions, router: Router
|
||||
}
|
||||
|
||||
const roomDefaults: RoomDefaults = {
|
||||
config: {
|
||||
name: video.name,
|
||||
description: '',
|
||||
language: video.language,
|
||||
// subject: video.name
|
||||
slow_mode_duration: await slowModeDuration(options, video.channelId)
|
||||
},
|
||||
config: Object.assign(
|
||||
{
|
||||
name: video.name,
|
||||
description: '',
|
||||
language: video.language
|
||||
// subject: video.name
|
||||
},
|
||||
await _getChannelSpecificOptions(options, video.channelId)
|
||||
),
|
||||
affiliations: affiliations
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user