mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-07-11 01:52:48 +00:00
Add report causes
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
//! # Server configuration
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::constants::{conservation_policy, MIN_SUPPORTED_MOBILE_VERSION, password_policy};
|
||||
@ -8,6 +10,7 @@ use crate::constants::accounts_info_policy::{MAX_FIRST_NAME_LENGTH, MAX_LAST_NAM
|
||||
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;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct NotificationsConfig {
|
||||
@ -63,6 +66,12 @@ struct AccountInformationPolicy {
|
||||
max_location_length: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ReportCause {
|
||||
id: &'static str,
|
||||
label: HashMap<&'static str, &'static str>,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ServerConfig {
|
||||
min_supported_mobile_version: &'static str,
|
||||
@ -78,6 +87,7 @@ pub struct ServerConfig {
|
||||
data_conservation_policy: DataConservationPolicy,
|
||||
conversations_policy: ConversationsPolicy,
|
||||
account_info_policy: AccountInformationPolicy,
|
||||
report_causes: Option<Vec<ReportCause>>,
|
||||
}
|
||||
|
||||
impl ServerConfig {
|
||||
@ -143,6 +153,17 @@ impl ServerConfig {
|
||||
max_last_name_length: MAX_LAST_NAME_LENGTH,
|
||||
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()),
|
||||
false => None
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user