mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-21 21:09:22 +00:00
Update database structure
This commit is contained in:
parent
5cb8ec6dba
commit
0eebfbe98a
@ -96,7 +96,7 @@ banner:
|
|||||||
link: https://about.communiquons.org/
|
link: https://about.communiquons.org/
|
||||||
|
|
||||||
# Allow bad content to be reported by users
|
# Allow bad content to be reported by users
|
||||||
allow_reporting: false
|
allow_reporting: true
|
||||||
|
|
||||||
# List of #Forez groups
|
# List of #Forez groups
|
||||||
#
|
#
|
||||||
|
@ -305,3 +305,12 @@ CREATE TABLE `comunic_admin_log` (
|
|||||||
`time` INT NULL,
|
`time` INT NULL,
|
||||||
`action` VARCHAR(255) NULL,
|
`action` VARCHAR(255) NULL,
|
||||||
PRIMARY KEY (`id`));
|
PRIMARY KEY (`id`));
|
||||||
|
|
||||||
|
CREATE TABLE `comunic_reports` (
|
||||||
|
`id` INT NOT NULL,
|
||||||
|
`user_id` INT NOT NULL,
|
||||||
|
`target` VARCHAR(25) NOT NULL,
|
||||||
|
`target_id` INT NOT NULL,
|
||||||
|
`time` INT NOT NULL,
|
||||||
|
`comment` TEXT NULL,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
@ -1 +1,9 @@
|
|||||||
-- Nothing yet
|
-- Create report table
|
||||||
|
CREATE TABLE `comunic_reports` (
|
||||||
|
`id` INT NOT NULL,
|
||||||
|
`user_id` INT NOT NULL,
|
||||||
|
`target` VARCHAR(25) NOT NULL,
|
||||||
|
`target_id` INT NOT NULL,
|
||||||
|
`time` INT NOT NULL,
|
||||||
|
`comment` TEXT NULL,
|
||||||
|
PRIMARY KEY (`id`));
|
||||||
|
@ -5,12 +5,12 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use serde::Serialize;
|
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::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::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::api_client::APIClient;
|
||||||
use crate::data::config::{Banner, conf};
|
use crate::data::config::{Banner, conf};
|
||||||
use crate::data::report_cause::REPORT_CAUSES;
|
use crate::data::report::REPORT_CAUSES;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NotificationsConfig {
|
struct NotificationsConfig {
|
||||||
@ -72,6 +72,12 @@ struct ReportCause {
|
|||||||
label: HashMap<&'static str, &'static str>,
|
label: HashMap<&'static str, &'static str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct ReportPolicy {
|
||||||
|
causes: Vec<ReportCause>,
|
||||||
|
max_comment_length: u32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
min_supported_mobile_version: &'static str,
|
min_supported_mobile_version: &'static str,
|
||||||
@ -87,7 +93,7 @@ pub struct ServerConfig {
|
|||||||
data_conservation_policy: DataConservationPolicy,
|
data_conservation_policy: DataConservationPolicy,
|
||||||
conversations_policy: ConversationsPolicy,
|
conversations_policy: ConversationsPolicy,
|
||||||
account_info_policy: AccountInformationPolicy,
|
account_info_policy: AccountInformationPolicy,
|
||||||
report_causes: Option<Vec<ReportCause>>,
|
report_policy: Option<ReportPolicy>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerConfig {
|
impl ServerConfig {
|
||||||
@ -154,14 +160,17 @@ impl ServerConfig {
|
|||||||
max_location_length: MAX_LOCATION_LENGTH,
|
max_location_length: MAX_LOCATION_LENGTH,
|
||||||
},
|
},
|
||||||
|
|
||||||
report_causes: match conf().allow_reporting {
|
report_policy: match conf().allow_reporting {
|
||||||
true => Some(REPORT_CAUSES.iter().map(|r| ReportCause {
|
true => Some(ReportPolicy {
|
||||||
id: r.id().id(),
|
causes: REPORT_CAUSES.iter().map(|r| ReportCause {
|
||||||
label: HashMap::from([
|
id: r.id().id(),
|
||||||
("fr", r.label_fr),
|
label: HashMap::from([
|
||||||
("en", r.label_en)
|
("fr", r.label_fr),
|
||||||
]),
|
("en", r.label_en)
|
||||||
}).collect()),
|
]),
|
||||||
|
}).collect(),
|
||||||
|
max_comment_length: reports::MAX_COMMENT_LENGTH,
|
||||||
|
}),
|
||||||
false => None
|
false => None
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -266,6 +266,12 @@ pub mod accounts_info_policy {
|
|||||||
/// Url where Firebase push notifications can be sent
|
/// Url where Firebase push notifications can be sent
|
||||||
pub const FIREBASE_PUSH_MESSAGE_URL: &str = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send";
|
pub const FIREBASE_PUSH_MESSAGE_URL: &str = "https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send";
|
||||||
|
|
||||||
|
/// Reports constants
|
||||||
|
pub mod reports {
|
||||||
|
/// Maximum report comment length
|
||||||
|
pub const MAX_COMMENT_LENGTH: u32 = 500;
|
||||||
|
}
|
||||||
|
|
||||||
/// Admin-specific constants
|
/// Admin-specific constants
|
||||||
pub mod admin {
|
pub mod admin {
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||||
|
@ -45,4 +45,4 @@ pub mod admin;
|
|||||||
pub mod webauthn_config;
|
pub mod webauthn_config;
|
||||||
pub mod admin_action_log;
|
pub mod admin_action_log;
|
||||||
pub mod u64_visitor;
|
pub mod u64_visitor;
|
||||||
pub mod report_cause;
|
pub mod report;
|
@ -5,7 +5,6 @@ use crate::data::group_id::GroupID;
|
|||||||
use crate::data::post::PostID;
|
use crate::data::post::PostID;
|
||||||
use crate::data::user::UserID;
|
use crate::data::user::UserID;
|
||||||
|
|
||||||
|
|
||||||
pub enum ReportTarget {
|
pub enum ReportTarget {
|
||||||
Post(PostID),
|
Post(PostID),
|
||||||
Comment(CommentID),
|
Comment(CommentID),
|
||||||
@ -64,7 +63,11 @@ impl ReportCause {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Ord, PartialOrd, Eq, PartialEq, Hash, Copy, Clone)]
|
||||||
|
pub struct ReportID(pub u64);
|
||||||
|
|
||||||
pub struct Report {
|
pub struct Report {
|
||||||
|
pub id: ReportID,
|
||||||
pub user_id: UserID,
|
pub user_id: UserID,
|
||||||
pub target: ReportTarget,
|
pub target: ReportTarget,
|
||||||
pub time: u64,
|
pub time: u64,
|
Loading…
Reference in New Issue
Block a user