fix: remove max upload size from settings / use env var instead to centralize the config

This commit is contained in:
Mohamed Marrouchi
2024-12-27 17:22:35 +01:00
parent bb83cd53bc
commit 99c702de17
17 changed files with 63 additions and 91 deletions

View File

@@ -17,6 +17,5 @@
"show_emoji": "Enable Emoji Picker",
"show_file": "Enable Attachment Uploader",
"show_location": "Enable Geolocation Share",
"allowed_upload_size": "Max Upload Size (in bytes)",
"allowed_upload_types": "Allowed Upload Mime Types (comma separated)"
}

View File

@@ -17,6 +17,5 @@
"show_emoji": "Activer le sélecteur d'Emojis",
"show_file": "Activer l'upload de fichiers",
"show_location": "Activer le partage de géolocalisation",
"allowed_upload_size": "Taille maximale de téléchargement (en octets)",
"allowed_upload_types": "Types MIME autorisés pour le téléchargement (séparés par des virgules)"
}

View File

@@ -10,8 +10,6 @@ import { ChannelSetting } from '@/channel/types';
import { config } from '@/config';
import { SettingType } from '@/setting/schemas/types';
import { Web } from '../web/types';
export const CONSOLE_CHANNEL_NAME = 'console-channel';
export const CONSOLE_CHANNEL_NAMESPACE = 'console_channel';
@@ -19,68 +17,62 @@ export const CONSOLE_CHANNEL_NAMESPACE = 'console_channel';
export default [
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_domains,
label: 'allowed_domains',
value: config.security.cors.allowOrigins.join(','),
type: SettingType.text,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.start_button,
label: 'start_button',
value: true,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.input_disabled,
label: 'input_disabled',
value: false,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.persistent_menu,
label: 'persistent_menu',
value: true,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.greeting_message,
label: 'greeting_message',
value: 'Welcome! Ready to start a conversation with our chatbot?',
type: SettingType.textarea,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.theme_color,
label: 'theme_color',
value: 'teal',
type: SettingType.select,
options: ['teal', 'orange', 'red', 'green', 'blue', 'dark'],
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_emoji,
label: 'show_emoji',
value: true,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_file,
label: 'show_file',
value: true,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_location,
label: 'show_location',
value: true,
type: SettingType.checkbox,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_upload_size,
value: 2500000,
type: SettingType.number,
},
{
group: CONSOLE_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_upload_types,
label: 'allowed_upload_types',
value:
'audio/mpeg,audio/x-ms-wma,audio/vnd.rn-realaudio,audio/x-wav,image/gif,image/jpeg,image/png,image/tiff,image/vnd.microsoft.icon,image/vnd.djvu,image/svg+xml,text/css,text/csv,text/html,text/plain,text/xml,video/mpeg,video/mp4,video/quicktime,video/x-ms-wmv,video/x-msvideo,video/x-flv,video/web,application/msword,application/vnd.ms-powerpoint,application/pdf,application/vnd.ms-excel,application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.tex,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.graphics,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document',
type: SettingType.textarea,

View File

@@ -17,6 +17,5 @@
"show_emoji": "Enable Emoji Picker",
"show_file": "Enable Attachment Uploader",
"show_location": "Enable Geolocation Share",
"allowed_upload_size": "Max Upload Size (in bytes)",
"allowed_upload_types": "Allowed Upload Mime Types (comma separated)"
}

View File

@@ -17,6 +17,5 @@
"show_emoji": "Activer le sélecteur d'Emojis",
"show_file": "Activer l'upload de fichiers",
"show_location": "Activer le partage de géolocalisation",
"allowed_upload_size": "Taille maximale de téléchargement (en octets)",
"allowed_upload_types": "Types MIME autorisés pour le téléchargement (séparés par des virgules)"
}

View File

@@ -9,8 +9,6 @@
import { ChannelSetting } from '@/channel/types';
import { SettingType } from '@/setting/schemas/types';
import { Web } from './types';
export const WEB_CHANNEL_NAME = 'web-channel' as const;
export const WEB_CHANNEL_NAMESPACE = 'web_channel';
@@ -18,82 +16,76 @@ export const WEB_CHANNEL_NAMESPACE = 'web_channel';
export default [
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_domains,
label: 'allowed_domains',
value: 'http://localhost:8080,http://localhost:4000',
type: SettingType.text,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.start_button,
label: 'start_button',
value: true,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.input_disabled,
label: 'input_disabled',
value: false,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.persistent_menu,
label: 'persistent_menu',
value: true,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.greeting_message,
label: 'greeting_message',
value: 'Welcome! Ready to start a conversation with our chatbot?',
type: SettingType.textarea,
translatable: true,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.theme_color,
label: 'theme_color',
value: 'teal',
type: SettingType.select,
options: ['teal', 'orange', 'red', 'green', 'blue', 'dark'],
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.window_title,
label: 'window_title',
value: 'Widget Title',
type: SettingType.text,
translatable: true,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.avatar_url,
label: 'avatar_url',
value: '',
type: SettingType.text,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_emoji,
label: 'show_emoji',
value: true,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_file,
label: 'show_file',
value: true,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.show_location,
label: 'show_location',
value: true,
type: SettingType.checkbox,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_upload_size,
value: 2500000,
type: SettingType.number,
},
{
group: WEB_CHANNEL_NAMESPACE,
label: Web.SettingLabel.allowed_upload_types,
label: 'allowed_upload_types',
value:
'audio/mpeg,audio/x-ms-wma,audio/vnd.rn-realaudio,audio/x-wav,image/gif,image/jpeg,image/png,image/tiff,image/vnd.microsoft.icon,image/vnd.djvu,image/svg+xml,text/css,text/csv,text/html,text/plain,text/xml,video/mpeg,video/mp4,video/quicktime,video/x-ms-wmv,video/x-msvideo,video/x-flv,video/web,application/msword,application/vnd.ms-powerpoint,application/pdf,application/vnd.ms-excel,application/vnd.oasis.opendocument.presentation,application/vnd.oasis.opendocument.tex,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.graphics,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document',
type: SettingType.textarea,

View File

@@ -12,24 +12,6 @@ import { FileType } from '@/chat/schemas/types/message';
import { StdQuickReply } from '@/chat/schemas/types/quick-reply';
export namespace Web {
export enum SettingLabel {
allowed_domains = 'allowed_domains',
start_button = 'start_button',
input_disabled = 'input_disabled',
persistent_menu = 'persistent_menu',
greeting_message = 'greeting_message',
theme_color = 'theme_color',
window_title = 'window_title',
avatar_url = 'avatar_url',
show_emoji = 'show_emoji',
show_file = 'show_file',
show_location = 'show_location',
allowed_upload_size = 'allowed_upload_size',
allowed_upload_types = 'allowed_upload_types',
}
export type Settings = Record<SettingLabel, any>;
export type RequestSession = {
web?: {
profile: SubscriberFull;