Moderation delay WIP (#132):
* default channel value for moderation delay
This commit is contained in:
parent
00a0dca1f9
commit
7a54594967
@ -1,6 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## ??? (Not Released Yet)
|
## 10.3.0 (Not Released Yet)
|
||||||
|
|
||||||
### Minor changes and fixes
|
### 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_TOKEN_ACTION_REVOKE_CONFIRM: string
|
||||||
|
|
||||||
declare const LOC_POLL_VOTE_OK: 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')}
|
${el.renderFeedback('peertube-livechat-slowmode-duration-feedback', 'slowMode.duration')}
|
||||||
</div>
|
</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
|
<livechat-configuration-section-header
|
||||||
.label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)}
|
.label=${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE)}
|
||||||
.description=${''}
|
.description=${''}
|
||||||
|
@ -34,8 +34,10 @@ export class ChannelDetailsService {
|
|||||||
|
|
||||||
const botConf = channelConfigurationOptions.bot
|
const botConf = channelConfigurationOptions.bot
|
||||||
const slowModeDuration = channelConfigurationOptions.slowMode.duration
|
const slowModeDuration = channelConfigurationOptions.slowMode.duration
|
||||||
|
const moderationDelay = channelConfigurationOptions.moderation.delay
|
||||||
|
|
||||||
propertiesError['slowMode.duration'] = []
|
propertiesError['slowMode.duration'] = []
|
||||||
|
propertiesError['moderation.delay'] = []
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(typeof slowModeDuration !== 'number') ||
|
(typeof slowModeDuration !== 'number') ||
|
||||||
@ -49,6 +51,18 @@ export class ChannelDetailsService {
|
|||||||
propertiesError['slowMode.duration'].push(ValidationErrorType.NotInRange)
|
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:
|
// If !bot.enabled, we don't have to validate these fields:
|
||||||
// The backend will ignore those values.
|
// The backend will ignore those values.
|
||||||
if (botConf.enabled) {
|
if (botConf.enabled) {
|
||||||
|
@ -579,3 +579,11 @@ poll_is_over: This poll is now over.
|
|||||||
poll_choice_invalid: This choice is not valid.
|
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_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.
|
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;
|
must104 = true;
|
||||||
end
|
end
|
||||||
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
|
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.
|
-- 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
|
if set_muc_terms then
|
||||||
|
@ -7,11 +7,14 @@
|
|||||||
-- This version contains a modification to take into account new config options:
|
-- This version contains a modification to take into account new config options:
|
||||||
-- * "slow_mode_duration"
|
-- * "slow_mode_duration"
|
||||||
-- * "mute_anonymous"
|
-- * "mute_anonymous"
|
||||||
|
-- * "moderation_delay"
|
||||||
-- These options are introduced in the Peertube livechat plugin.
|
-- These options are introduced in the Peertube livechat plugin.
|
||||||
--
|
--
|
||||||
-- The "slow_mode_duration" comes with mod_muc_slow_mode.
|
-- 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.
|
-- 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 http = require "net.http";
|
||||||
local async = require "util.async";
|
local async = require "util.async";
|
||||||
@ -116,7 +119,10 @@ local function apply_config(room, settings)
|
|||||||
|
|
||||||
-- specific to peertube-plugin-livechat:
|
-- specific to peertube-plugin-livechat:
|
||||||
if (type(config.slow_mode_duration) == "number") and config.slow_mode_duration >= 0 then
|
if (type(config.slow_mode_duration) == "number") and config.slow_mode_duration >= 0 then
|
||||||
room._data.slow_mode_duration = config.slow_mode_duration;
|
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
|
end
|
||||||
if (type(config.mute_anonymous) == "boolean") then
|
if (type(config.mute_anonymous) == "boolean") then
|
||||||
room._data.x_peertubelivechat_mute_anonymous = config.mute_anonymous;
|
room._data.x_peertubelivechat_mute_anonymous = config.mute_anonymous;
|
||||||
|
@ -36,6 +36,9 @@ async function sanitizeChannelConfigurationOptions (
|
|||||||
throw new Error('Invalid data.slowMode data type')
|
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
|
// mute not present in livechat <= 10.2.0
|
||||||
const mute = data.mute ?? {}
|
const mute = data.mute ?? {}
|
||||||
mute.anonymous ??= false
|
mute.anonymous ??= false
|
||||||
@ -68,6 +71,9 @@ async function sanitizeChannelConfigurationOptions (
|
|||||||
},
|
},
|
||||||
mute: {
|
mute: {
|
||||||
anonymous: _readBoolean(mute, 'anonymous')
|
anonymous: _readBoolean(mute, 'anonymous')
|
||||||
|
},
|
||||||
|
moderation: {
|
||||||
|
delay: _readInteger(moderationData, 'delay', 0, 60)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (terms !== undefined) {
|
if (terms !== undefined) {
|
||||||
|
@ -53,6 +53,9 @@ function getDefaultChannelConfigurationOptions (_options: RegisterServerOptions)
|
|||||||
mute: {
|
mute: {
|
||||||
anonymous: false
|
anonymous: false
|
||||||
},
|
},
|
||||||
|
moderation: {
|
||||||
|
delay: 0
|
||||||
|
},
|
||||||
terms: undefined
|
terms: undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ async function updateProsodyRoom (
|
|||||||
data: {
|
data: {
|
||||||
name?: string
|
name?: string
|
||||||
slow_mode_duration?: number
|
slow_mode_duration?: number
|
||||||
|
moderation_delay?: number
|
||||||
livechat_muc_terms?: string
|
livechat_muc_terms?: string
|
||||||
addAffiliations?: Affiliations
|
addAffiliations?: Affiliations
|
||||||
removeAffiliationsFor?: string[]
|
removeAffiliationsFor?: string[]
|
||||||
@ -93,6 +94,9 @@ async function updateProsodyRoom (
|
|||||||
if (('slow_mode_duration' in data) && data.slow_mode_duration !== undefined) {
|
if (('slow_mode_duration' in data) && data.slow_mode_duration !== undefined) {
|
||||||
apiData.slow_mode_duration = data.slow_mode_duration
|
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) {
|
if ('livechat_muc_terms' in data) {
|
||||||
apiData.livechat_muc_terms = data.livechat_muc_terms ?? ''
|
apiData.livechat_muc_terms = data.livechat_muc_terms ?? ''
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ interface RoomDefaults {
|
|||||||
slow_mode_duration?: number
|
slow_mode_duration?: number
|
||||||
mute_anonymous?: boolean
|
mute_anonymous?: boolean
|
||||||
livechat_muc_terms?: string
|
livechat_muc_terms?: string
|
||||||
|
moderation_delay?: number
|
||||||
}
|
}
|
||||||
affiliations?: Affiliations
|
affiliations?: Affiliations
|
||||||
}
|
}
|
||||||
@ -52,7 +53,8 @@ async function _getChannelSpecificOptions (
|
|||||||
return {
|
return {
|
||||||
slow_mode_duration: channelOptions.slowMode.duration,
|
slow_mode_duration: channelOptions.slowMode.duration,
|
||||||
mute_anonymous: channelOptions.mute.anonymous,
|
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?)
|
// nonFollowers: boolean (or a number of seconds?)
|
||||||
}
|
}
|
||||||
terms?: string // comes with Livechat 10.2.0
|
terms?: string // comes with Livechat 10.2.0
|
||||||
|
moderation: { // comes with Livechat 10.3.0
|
||||||
|
delay: number
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChannelForbiddenWords {
|
interface ChannelForbiddenWords {
|
||||||
|
Loading…
Reference in New Issue
Block a user