Moderation delay WIP (#132):
* default channel value for moderation delay
This commit is contained in:
parent
00a0dca1f9
commit
7a54594967
@ -1,6 +1,6 @@
|
||||
# Changelog
|
||||
|
||||
## ??? (Not Released Yet)
|
||||
## 10.3.0 (Not Released Yet)
|
||||
|
||||
### Minor changes and fixes
|
||||
|
||||
|
3
client/@types/global.d.ts
vendored
3
client/@types/global.d.ts
vendored
@ -130,3 +130,6 @@ declare const LOC_TOKEN_DEFAULT_LABEL: string
|
||||
declare const LOC_TOKEN_ACTION_REVOKE_CONFIRM: string
|
||||
|
||||
declare const LOC_POLL_VOTE_OK: string
|
||||
|
||||
declare const LOC_MODERATION_DELAY: string
|
||||
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_MODERATION_DELAY_DESC: string
|
||||
|
@ -219,6 +219,41 @@ export function tplChannelConfiguration (el: ChannelConfigurationElement): Templ
|
||||
${el.renderFeedback('peertube-livechat-slowmode-duration-feedback', 'slowMode.duration')}
|
||||
</div>
|
||||
|
||||
<livechat-configuration-section-header
|
||||
.label=${ptTr(LOC_MODERATION_DELAY)}
|
||||
.description=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_MODERATION_DELAY_DESC, true)}
|
||||
.helpPage=${'documentation/user/streamers/moderation_delay'}>
|
||||
</livechat-configuration-section-header>
|
||||
<div class="form-group">
|
||||
<label>
|
||||
${ptTr(LOC_MODERATION_DELAY)}
|
||||
<input
|
||||
type="number"
|
||||
name="moderation_delay"
|
||||
class=${classMap(
|
||||
Object.assign(
|
||||
{ 'form-control': true },
|
||||
el.getInputValidationClass('moderation.delay')
|
||||
)
|
||||
)}
|
||||
min="0"
|
||||
max="60"
|
||||
id="peertube-livechat-moderation-delay"
|
||||
aria-describedby="peertube-livechat-moderation-delay-feedback"
|
||||
@input=${(event: InputEvent) => {
|
||||
if (event?.target && el.channelConfiguration) {
|
||||
el.channelConfiguration.configuration.moderation.delay =
|
||||
Number((event.target as HTMLInputElement).value)
|
||||
}
|
||||
el.requestUpdate('channelConfiguration')
|
||||
}
|
||||
}
|
||||
value="${el.channelConfiguration?.configuration.moderation.delay ?? ''}"
|
||||
/>
|
||||
</label>
|
||||
${el.renderFeedback('peertube-livechat-moderation-delay-feedback', 'moderation.delay')}
|
||||
</div>
|
||||
|
||||
<livechat-configuration-section-header
|
||||
.label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)}
|
||||
.description=${''}
|
||||
|
@ -34,8 +34,10 @@ export class ChannelDetailsService {
|
||||
|
||||
const botConf = channelConfigurationOptions.bot
|
||||
const slowModeDuration = channelConfigurationOptions.slowMode.duration
|
||||
const moderationDelay = channelConfigurationOptions.moderation.delay
|
||||
|
||||
propertiesError['slowMode.duration'] = []
|
||||
propertiesError['moderation.delay'] = []
|
||||
|
||||
if (
|
||||
(typeof slowModeDuration !== 'number') ||
|
||||
@ -49,6 +51,18 @@ export class ChannelDetailsService {
|
||||
propertiesError['slowMode.duration'].push(ValidationErrorType.NotInRange)
|
||||
}
|
||||
|
||||
if (
|
||||
(typeof moderationDelay !== 'number') ||
|
||||
isNaN(moderationDelay)
|
||||
) {
|
||||
propertiesError['moderation.delay'].push(ValidationErrorType.WrongType)
|
||||
} else if (
|
||||
moderationDelay < 0 ||
|
||||
moderationDelay > 60
|
||||
) {
|
||||
propertiesError['moderation.delay'].push(ValidationErrorType.NotInRange)
|
||||
}
|
||||
|
||||
// If !bot.enabled, we don't have to validate these fields:
|
||||
// The backend will ignore those values.
|
||||
if (botConf.enabled) {
|
||||
|
@ -579,3 +579,11 @@ poll_is_over: This poll is now over.
|
||||
poll_choice_invalid: This choice is not valid.
|
||||
poll_anonymous_vote_ok: Your vote is taken into account. Votes are anonymous, they will not be shown to other participants.
|
||||
poll_vote_ok: Your vote has been taking into account, the counters will be updated in a moment.
|
||||
|
||||
moderation_delay: Moderation delay
|
||||
livechat_configuration_channel_moderation_delay_desc: |
|
||||
Moderation delay default value:
|
||||
<ul>
|
||||
<li>0: moderation delay disabled</li>
|
||||
<li>Any positive integer: messages will be delayed for X seconds for non-moderator participants, allowing moderators to delete message before any user can read it.</li>
|
||||
</ul>
|
||||
|
@ -97,6 +97,11 @@ local function update_room(event)
|
||||
must104 = true;
|
||||
end
|
||||
end
|
||||
if type(config.moderation_delay) == "number" then
|
||||
if room._data.moderation_delay ~= config.moderation_delay then
|
||||
room._data.moderation_delay = config.moderation_delay;
|
||||
end
|
||||
end
|
||||
if (type(config.livechat_muc_terms) == "string") then
|
||||
-- to easily detect if the value is given or not, we consider that the caller passes "" when terms must be deleted.
|
||||
if set_muc_terms then
|
||||
|
@ -7,11 +7,14 @@
|
||||
-- This version contains a modification to take into account new config options:
|
||||
-- * "slow_mode_duration"
|
||||
-- * "mute_anonymous"
|
||||
-- * "moderation_delay"
|
||||
-- These options are introduced in the Peertube livechat plugin.
|
||||
--
|
||||
-- The "slow_mode_duration" comes with mod_muc_slow_mode.
|
||||
-- There will be a XEP proposal for this one. When done, these modifications will be submitted to the mod_muc_http_defaults maintainer.
|
||||
--
|
||||
-- The "moderation_delay" comes with mod_muc_moderation_delay
|
||||
--
|
||||
|
||||
local http = require "net.http";
|
||||
local async = require "util.async";
|
||||
@ -118,6 +121,9 @@ local function apply_config(room, settings)
|
||||
if (type(config.slow_mode_duration) == "number") and config.slow_mode_duration >= 0 then
|
||||
room._data.slow_mode_duration = config.slow_mode_duration;
|
||||
end
|
||||
if (type(config.moderation_delay) == "number") and config.moderation_delay >= 0 then
|
||||
room._data.moderation_delay = config.moderation_delay;
|
||||
end
|
||||
if (type(config.mute_anonymous) == "boolean") then
|
||||
room._data.x_peertubelivechat_mute_anonymous = config.mute_anonymous;
|
||||
end
|
||||
|
@ -36,6 +36,9 @@ async function sanitizeChannelConfigurationOptions (
|
||||
throw new Error('Invalid data.slowMode data type')
|
||||
}
|
||||
|
||||
const moderationData = data.moderation ?? {} // comes with livechat 10.3.0
|
||||
moderationData.delay ??= 0
|
||||
|
||||
// mute not present in livechat <= 10.2.0
|
||||
const mute = data.mute ?? {}
|
||||
mute.anonymous ??= false
|
||||
@ -68,6 +71,9 @@ async function sanitizeChannelConfigurationOptions (
|
||||
},
|
||||
mute: {
|
||||
anonymous: _readBoolean(mute, 'anonymous')
|
||||
},
|
||||
moderation: {
|
||||
delay: _readInteger(moderationData, 'delay', 0, 60)
|
||||
}
|
||||
}
|
||||
if (terms !== undefined) {
|
||||
|
@ -53,6 +53,9 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
|
||||
mute: {
|
||||
anonymous: false
|
||||
},
|
||||
moderation: {
|
||||
delay: 0
|
||||
},
|
||||
terms: undefined
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ async function updateProsodyRoom (
|
||||
data: {
|
||||
name?: string
|
||||
slow_mode_duration?: number
|
||||
moderation_delay?: number
|
||||
livechat_muc_terms?: string
|
||||
addAffiliations?: Affiliations
|
||||
removeAffiliationsFor?: string[]
|
||||
@ -93,6 +94,9 @@ async function updateProsodyRoom (
|
||||
if (('slow_mode_duration' in data) && data.slow_mode_duration !== undefined) {
|
||||
apiData.slow_mode_duration = data.slow_mode_duration
|
||||
}
|
||||
if (('moderation_delay' in data) && data.moderation_delay !== undefined) {
|
||||
apiData.moderation_delay = data.moderation_delay
|
||||
}
|
||||
if ('livechat_muc_terms' in data) {
|
||||
apiData.livechat_muc_terms = data.livechat_muc_terms ?? ''
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ interface RoomDefaults {
|
||||
slow_mode_duration?: number
|
||||
mute_anonymous?: boolean
|
||||
livechat_muc_terms?: string
|
||||
moderation_delay?: number
|
||||
}
|
||||
affiliations?: Affiliations
|
||||
}
|
||||
@ -52,7 +53,8 @@ async function _getChannelSpecificOptions (
|
||||
return {
|
||||
slow_mode_duration: channelOptions.slowMode.duration,
|
||||
mute_anonymous: channelOptions.mute.anonymous,
|
||||
livechat_muc_terms: channelOptions.terms
|
||||
livechat_muc_terms: channelOptions.terms,
|
||||
moderation_delay: channelOptions.moderation.delay
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,9 @@ interface ChannelConfigurationOptions {
|
||||
// nonFollowers: boolean (or a number of seconds?)
|
||||
}
|
||||
terms?: string // comes with Livechat 10.2.0
|
||||
moderation: { // comes with Livechat 10.3.0
|
||||
delay: number
|
||||
}
|
||||
}
|
||||
|
||||
interface ChannelForbiddenWords {
|
||||
|
Loading…
Reference in New Issue
Block a user