Forbidden words comment field.

This commit is contained in:
John Livingston
2023-09-25 13:16:15 +02:00
parent 06b9417650
commit b8aef07182
8 changed files with 51 additions and 3 deletions

View File

@ -55,6 +55,8 @@ declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_LABEL: s
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_LABEL: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_DESC: string
declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL: string

View File

@ -101,6 +101,16 @@
/>
<p class="form-group-description">{{forbiddenWordsReasonDesc}}</p>
</div>
<div class="form-group">
<label for="peertube-livechat-forbidden-words-comments-{{fieldNumber}}">{{forbiddenWordsComments}}</label>
{{! warning: don't add extra line break in textarea! }}
<textarea
name="forbidden_words_comments_{{fieldNumber}}"
id="peertube-livechat-forbidden-words-comments-{{fieldNumber}}"
class="form-control"
>{{comments}}</textarea>
<p class="form-group-description">{{forbiddenWordsCommentsDesc}}</p>
</div>
</div>
</div>
{{/forbiddenWordsArray}}

View File

@ -91,6 +91,12 @@ async function fillLabels (
view.forbiddenWordsApplyToModeratorsDesc = await peertubeHelpers.translate(
LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC
)
view.forbiddenWordsComments = await peertubeHelpers.translate(
LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL
)
view.forbiddenWordsCommentsDesc = await peertubeHelpers.translate(
LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC
)
view.quoteLabel = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL)
view.quoteDesc = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC)
view.quoteDesc2 = await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2)

View File

@ -43,7 +43,8 @@ async function getConfigurationChannelViewData (
joinedEntries: fw.entries.join('\n'),
regexp: !!fw.regexp,
applyToModerators: fw.applyToModerators,
reason: fw.reason
reason: fw.reason,
comments: fw.comments
})
}
// Ensuring we have at least N blocks:
@ -57,7 +58,8 @@ async function getConfigurationChannelViewData (
joinedEntries: '',
regexp: false,
applyToModerators: false,
reason: ''
reason: '',
comments: ''
})
continue
}
@ -231,6 +233,7 @@ async function vivifyConfigurationChannel (
const regexp = data.get('forbidden_words_regexp_' + i.toString())
const applyToModerators = data.get('forbidden_words_applytomoderators_' + i.toString())
const reason = data.get('forbidden_words_reason_' + i.toString())?.toString()
const comments = data.get('forbidden_words_comments_' + i.toString())?.toString()
const fw: ChannelConfigurationOptions['bot']['forbiddenWords'][0] = {
entries,
applyToModerators: !!applyToModerators,
@ -239,6 +242,9 @@ async function vivifyConfigurationChannel (
if (reason) {
fw.reason = reason
}
if (comments) {
fw.comments = comments
}
channelConfigurationOptions.bot.forbiddenWords.push(fw)
}