mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-10 17:42:48 +00:00
Update database structure
This commit is contained in:
@ -5,12 +5,12 @@ use std::collections::HashMap;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy};
|
||||
use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy, reports};
|
||||
use crate::constants::accounts_info_policy::{MAX_FIRST_NAME_LENGTH, MAX_LAST_NAME_LENGTH, MAX_LOCATION_LENGTH, MIN_FIRST_NAME_LENGTH, MIN_LAST_NAME_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::api_client::APIClient;
|
||||
use crate::data::config::{Banner, conf};
|
||||
use crate::data::report_cause::REPORT_CAUSES;
|
||||
use crate::data::report::REPORT_CAUSES;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct NotificationsConfig {
|
||||
@ -72,6 +72,12 @@ struct ReportCause {
|
||||
label: HashMap<&'static str, &'static str>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ReportPolicy {
|
||||
causes: Vec<ReportCause>,
|
||||
max_comment_length: u32,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ServerConfig {
|
||||
min_supported_mobile_version: &'static str,
|
||||
@ -87,7 +93,7 @@ pub struct ServerConfig {
|
||||
data_conservation_policy: DataConservationPolicy,
|
||||
conversations_policy: ConversationsPolicy,
|
||||
account_info_policy: AccountInformationPolicy,
|
||||
report_causes: Option<Vec<ReportCause>>,
|
||||
report_policy: Option<ReportPolicy>,
|
||||
}
|
||||
|
||||
impl ServerConfig {
|
||||
@ -154,14 +160,17 @@ impl ServerConfig {
|
||||
max_location_length: MAX_LOCATION_LENGTH,
|
||||
},
|
||||
|
||||
report_causes: match conf().allow_reporting {
|
||||
true => Some(REPORT_CAUSES.iter().map(|r| ReportCause {
|
||||
id: r.id().id(),
|
||||
label: HashMap::from([
|
||||
("fr", r.label_fr),
|
||||
("en", r.label_en)
|
||||
]),
|
||||
}).collect()),
|
||||
report_policy: match conf().allow_reporting {
|
||||
true => Some(ReportPolicy {
|
||||
causes: REPORT_CAUSES.iter().map(|r| ReportCause {
|
||||
id: r.id().id(),
|
||||
label: HashMap::from([
|
||||
("fr", r.label_fr),
|
||||
("en", r.label_en)
|
||||
]),
|
||||
}).collect(),
|
||||
max_comment_length: reports::MAX_COMMENT_LENGTH,
|
||||
}),
|
||||
false => None
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user