1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-12-27 22:18:51 +00:00

Define a max length for conversations name

This commit is contained in:
Pierre HUBERT 2021-04-06 16:40:00 +02:00
parent 6365e2d2b3
commit d53f0aae7b
2 changed files with 6 additions and 1 deletions

View File

@ -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,

View File

@ -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;