mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Expose to on server configuration max conversation images width
This commit is contained in:
		@@ -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_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_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH};
 | 
			
		||||
use crate::data::config::conf;
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize)]
 | 
			
		||||
@@ -37,6 +37,10 @@ struct ConversationsPolicy {
 | 
			
		||||
    files_max_size: usize,
 | 
			
		||||
    writing_event_interval: u64,
 | 
			
		||||
    writing_event_lifetime: u64,
 | 
			
		||||
    max_message_image_width: u32,
 | 
			
		||||
    max_message_image_height: u32,
 | 
			
		||||
    max_thumbnail_width: u32,
 | 
			
		||||
    max_thumbnail_height: u32,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[derive(Serialize)]
 | 
			
		||||
@@ -87,7 +91,11 @@ impl ServerConfig {
 | 
			
		||||
                files_max_size: CONVERSATION_FILES_MAX_SIZE,
 | 
			
		||||
                writing_event_interval: CONVERSATION_WRITING_EVENT_INTERVAL,
 | 
			
		||||
                writing_event_lifetime: CONVERSATION_WRITING_EVENT_LIFETIME,
 | 
			
		||||
                max_message_image_width: MAX_CONV_IMAGE_MESSAGE_WIDTH,
 | 
			
		||||
                max_message_image_height: MAX_CONV_IMAGE_MESSAGE_WIDTH,
 | 
			
		||||
                max_thumbnail_width: MAX_CONV_MESSAGE_THUMBNAIL_WIDTH,
 | 
			
		||||
                max_thumbnail_height: MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT,
 | 
			
		||||
            },
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -200,4 +200,12 @@ pub mod conversations {
 | 
			
		||||
 | 
			
		||||
    /// Lifetime of conversation writing event
 | 
			
		||||
    pub const CONVERSATION_WRITING_EVENT_LIFETIME: u64 = 3;
 | 
			
		||||
 | 
			
		||||
    /// Image size
 | 
			
		||||
    pub const MAX_CONV_IMAGE_MESSAGE_WIDTH: u32 = 2000;
 | 
			
		||||
    pub const MAX_CONV_IMAGE_MESSAGE_HEIGHT: u32 = 2000;
 | 
			
		||||
 | 
			
		||||
    /// Thumbnail size
 | 
			
		||||
    pub const MAX_CONV_MESSAGE_THUMBNAIL_WIDTH: u32 = 300;
 | 
			
		||||
    pub const MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT: u32 = 300;
 | 
			
		||||
}
 | 
			
		||||
@@ -12,7 +12,7 @@ use crate::api_data::res_count_unread_conversations::ResultCountUnreadConversati
 | 
			
		||||
use crate::api_data::res_create_conversation::ResCreateConversation;
 | 
			
		||||
use crate::api_data::res_find_private_conversations::ResFindPrivateConversations;
 | 
			
		||||
use crate::api_data::user_is_writing_message_in_conversation::UserIsWritingMessageInConversation;
 | 
			
		||||
use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, MAX_CONVERSATION_MESSAGE_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH};
 | 
			
		||||
use crate::constants::conversations::{ALLOWED_CONVERSATION_FILES_TYPES, CONVERSATION_FILES_MAX_SIZE, MAX_CONV_IMAGE_MESSAGE_HEIGHT, MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT, MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONVERSATION_MESSAGE_LENGTH, MIN_CONVERSATION_MESSAGE_LENGTH};
 | 
			
		||||
use crate::controllers::user_ws_controller;
 | 
			
		||||
use crate::data::base_request_handler::{BaseRequestHandler, RequestValue};
 | 
			
		||||
use crate::data::conversation::NewConversationSettings;
 | 
			
		||||
@@ -313,7 +313,7 @@ pub fn send_message(r: &mut HttpRequestHandler) -> RequestResult {
 | 
			
		||||
                    thumbnail = Some("file".to_string());
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                path = r.save_post_image("file", "conversation", 2000, 2000)?;
 | 
			
		||||
                path = r.save_post_image("file", "conversation", MAX_CONV_IMAGE_MESSAGE_WIDTH, MAX_CONV_IMAGE_MESSAGE_HEIGHT)?;
 | 
			
		||||
                mime_type = "image/png".to_string();
 | 
			
		||||
                name = "picture.png".to_string();
 | 
			
		||||
            }
 | 
			
		||||
@@ -352,7 +352,7 @@ pub fn send_message(r: &mut HttpRequestHandler) -> RequestResult {
 | 
			
		||||
            // Attempt to save thumbnail, if it fails we can not save message
 | 
			
		||||
            let thumbnail = match thumbnail {
 | 
			
		||||
                None => None,
 | 
			
		||||
                Some(f) => Some(match r.save_post_image(&f, "conversations-thumb", 300, 300) {
 | 
			
		||||
                Some(f) => Some(match r.save_post_image(&f, "conversations-thumb", MAX_CONV_MESSAGE_THUMBNAIL_WIDTH, MAX_CONV_MESSAGE_THUMBNAIL_HEIGHT) {
 | 
			
		||||
                    Ok(s) => Ok(s),
 | 
			
		||||
                    Err(e) => {
 | 
			
		||||
                        eprintln!("Failed to save conversation thumbnail! {:#?}", e);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user