From 4fe972dc106c8be57c160de6baad980f43075b13 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Tue, 19 Sep 2023 18:56:39 +0200 Subject: [PATCH] Configure bot name + refactoring. --- client/@types/global.d.ts | 1 + client/common/configuration/logic/channel.ts | 1 + .../common/configuration/templates/channel.ts | 9 ++ languages/en.yml | 2 +- server/lib/configuration/channel/sanitize.ts | 95 ++++++++++++------- server/lib/configuration/channel/storage.ts | 7 +- shared/lib/types.ts | 1 + 7 files changed, 78 insertions(+), 38 deletions(-) diff --git a/client/@types/global.d.ts b/client/@types/global.d.ts index 9f36709e..cf35c5ce 100644 --- a/client/@types/global.d.ts +++ b/client/@types/global.d.ts @@ -44,3 +44,4 @@ declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_ENABLE_BOT_LABEL: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_OPTIONS_TITLE: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL: string declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_BANNED_JIDS_LABEL: string +declare const LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_NICKNAME: string diff --git a/client/common/configuration/logic/channel.ts b/client/common/configuration/logic/channel.ts index feafa6b7..ae38adab 100644 --- a/client/common/configuration/logic/channel.ts +++ b/client/common/configuration/logic/channel.ts @@ -27,6 +27,7 @@ async function vivifyConfigurationChannel ( const data = new FormData(form) const channelConfigurationOptions: ChannelConfigurationOptions = { bot: data.get('bot') === '1', + botNickname: data.get('bot_nickname')?.toString() ?? '', bannedJIDs: (data.get('banned_jids')?.toString() ?? '').split(/\r?\n|\r|\n/g), forbiddenWords: (data.get('forbidden_words')?.toString() ?? '').split(/\r?\n|\r|\n/g) } diff --git a/client/common/configuration/templates/channel.ts b/client/common/configuration/templates/channel.ts index 43d47b4d..95eee3e5 100644 --- a/client/common/configuration/templates/channel.ts +++ b/client/common/configuration/templates/channel.ts @@ -47,6 +47,7 @@ async function renderConfigurationChannel ( bannedJIDs: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BANNED_JIDS_LABEL), save: await peertubeHelpers.translate(LOC_SAVE), cancel: await peertubeHelpers.translate(LOC_CANCEL), + botNickname: await peertubeHelpers.translate(LOC_LIVECHAT_CONFIGURATION_CHANNEL_BOT_NICKNAME), channelConfiguration } @@ -69,6 +70,14 @@ async function renderConfigurationChannel (
{{botOptions}} +