Slow mode WIP (#192):
* default delay is configurable in channel's chat rooms options.
This commit is contained in:
@ -23,6 +23,11 @@ async function sanitizeChannelConfigurationOptions (
|
||||
throw new Error('Invalid data.bot data type')
|
||||
}
|
||||
|
||||
const slowModeData = data.slowMode ?? { defaultDelay: 0 } // not present in livechat <= 8.2.0
|
||||
if (typeof slowModeData !== 'object') {
|
||||
throw new Error('Invalid data.slowMode data type')
|
||||
}
|
||||
|
||||
const result: ChannelConfigurationOptions = {
|
||||
bot: {
|
||||
enabled: _readBoolean(botData, 'enabled'),
|
||||
@ -31,6 +36,9 @@ async function sanitizeChannelConfigurationOptions (
|
||||
quotes: _readQuotes(botData),
|
||||
commands: _readCommands(botData)
|
||||
// TODO: bannedJIDs
|
||||
},
|
||||
slowMode: {
|
||||
defaultDelay: _readInteger(slowModeData, 'defaultDelay', 0, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ async function getChannelConfigurationOptions (
|
||||
const logger = options.peertubeHelpers.logger
|
||||
const filePath = _getFilePath(options, channelId)
|
||||
if (!fs.existsSync(filePath)) {
|
||||
logger.debug('No stored data for channel, returning default values')
|
||||
logger.debug('No stored data for channel, returning null')
|
||||
return null
|
||||
}
|
||||
const content = await fs.promises.readFile(filePath, {
|
||||
@ -42,6 +42,9 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
|
||||
forbiddenWords: [],
|
||||
quotes: [],
|
||||
commands: []
|
||||
},
|
||||
slowMode: {
|
||||
defaultDelay: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user