From d53f0aae7beaaf4a0277c537e6d332b7f4c3fadc Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 6 Apr 2021 16:40:00 +0200 Subject: [PATCH] Define a max length for conversations name --- src/api_data/server_config.rs | 4 +++- src/constants.rs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/api_data/server_config.rs b/src/api_data/server_config.rs index 16b3b41..e36dc8e 100644 --- a/src/api_data/server_config.rs +++ b/src/api_data/server_config.rs @@ -4,7 +4,7 @@ use serde::Serialize; use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy}; -use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, CONVERSATION_WRITING_EVENT_INTERVAL, CONVERSATION_WRITING_EVENT_LIFETIME, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH}; +use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, CONVERSATION_WRITING_EVENT_INTERVAL, CONVERSATION_WRITING_EVENT_LIFETIME, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_LOGO_HEIGHT, MAX_CONV_LOGO_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MAX_CONVERSATION_NAME_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH}; use crate::data::config::conf; #[derive(Serialize)] @@ -31,6 +31,7 @@ struct DataConservationPolicy { #[derive(Serialize)] struct ConversationsPolicy { + max_conversation_name_len: usize, min_message_len: usize, max_message_len: usize, allowed_files_type: [&'static str; 17], @@ -87,6 +88,7 @@ impl ServerConfig { }, conversations_policy: ConversationsPolicy { + max_conversation_name_len: MAX_CONVERSATION_NAME_LENGTH, min_message_len: MIN_CONVERSATION_MESSAGE_LENGTH, max_message_len: MAX_CONVERSATION_MESSAGE_LENGTH, allowed_files_type: ALLOWED_CONVERSATION_FILES_TYPES, diff --git a/src/constants.rs b/src/constants.rs index c94470d..a594a6e 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -166,6 +166,9 @@ pub const MIN_SUPPORTED_MOBILE_VERSION: &str = "1.1.2"; /// Conversations constants pub mod conversations { + /// Conversation name + pub const MAX_CONVERSATION_NAME_LENGTH: usize = 20; + /// Minimum message length pub const MIN_CONVERSATION_MESSAGE_LENGTH: usize = 1; pub const MAX_CONVERSATION_MESSAGE_LENGTH: usize = 16000;