mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-21 21:09:22 +00:00
Add report causes
This commit is contained in:
parent
d440ab5145
commit
5cb8ec6dba
10
config.yaml
10
config.yaml
@ -14,7 +14,7 @@ server-port: 3000
|
|||||||
proxy: "127.0.0.1"
|
proxy: "127.0.0.1"
|
||||||
|
|
||||||
# User data storage
|
# User data storage
|
||||||
storage-url: http://devweb.local/comunic/current/user_data/
|
storage-url: http://devweb.internal/comunic/current/user_data/
|
||||||
storage-path: /home/pierre/Documents/projets_web/comunic/current/user_data/
|
storage-path: /home/pierre/Documents/projets_web/comunic/current/user_data/
|
||||||
|
|
||||||
# Specify whether user data files should be made available under the user_data directory
|
# Specify whether user data files should be made available under the user_data directory
|
||||||
@ -23,14 +23,14 @@ storage-path: /home/pierre/Documents/projets_web/comunic/current/user_data/
|
|||||||
serve-storage-files: true
|
serve-storage-files: true
|
||||||
|
|
||||||
# URL where Comunic Terms of use are available
|
# URL where Comunic Terms of use are available
|
||||||
terms-url: http://devweb.local/comunic/current/about.php?cgu
|
terms-url: http://devweb.internal/comunic/current/about.php?cgu
|
||||||
privacy-policy-url: http://devweb.local/comunic/current/about.php?cgu&privacy
|
privacy-policy-url: http://devweb.internal/comunic/current/about.php?cgu&privacy
|
||||||
|
|
||||||
# Email where the Comunic staff can be contacted
|
# Email where the Comunic staff can be contacted
|
||||||
contact-email: contact@communiquons.org
|
contact-email: contact@communiquons.org
|
||||||
|
|
||||||
# Password reset URL pattern
|
# Password reset URL pattern
|
||||||
password-reset-url: https://devweb.local/comunic/v2/reset_password?token=#{TOKEN}
|
password-reset-url: https://devweb.internal/comunic/v2/reset_password?token=#{TOKEN}
|
||||||
|
|
||||||
# Android application download URL
|
# Android application download URL
|
||||||
play-store-url: https://play.google.com/store/apps/details?id=org.communiquons.comunic
|
play-store-url: https://play.google.com/store/apps/details?id=org.communiquons.comunic
|
||||||
@ -95,6 +95,8 @@ banner:
|
|||||||
# Optional URL to "learn more" about the message. Leave an empty value to disable
|
# Optional URL to "learn more" about the message. Leave an empty value to disable
|
||||||
link: https://about.communiquons.org/
|
link: https://about.communiquons.org/
|
||||||
|
|
||||||
|
# Allow bad content to be reported by users
|
||||||
|
allow_reporting: false
|
||||||
|
|
||||||
# List of #Forez groups
|
# List of #Forez groups
|
||||||
#
|
#
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
//! # Server configuration
|
//! # Server configuration
|
||||||
//!
|
//!
|
||||||
//! @author Pierre Hubert
|
//! @author Pierre Hubert
|
||||||
|
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};
|
||||||
@ -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::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;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NotificationsConfig {
|
struct NotificationsConfig {
|
||||||
@ -63,6 +66,12 @@ struct AccountInformationPolicy {
|
|||||||
max_location_length: usize,
|
max_location_length: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize)]
|
||||||
|
struct ReportCause {
|
||||||
|
id: &'static str,
|
||||||
|
label: HashMap<&'static str, &'static str>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct ServerConfig {
|
pub struct ServerConfig {
|
||||||
min_supported_mobile_version: &'static str,
|
min_supported_mobile_version: &'static str,
|
||||||
@ -78,6 +87,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>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerConfig {
|
impl ServerConfig {
|
||||||
@ -143,6 +153,17 @@ impl ServerConfig {
|
|||||||
max_last_name_length: MAX_LAST_NAME_LENGTH,
|
max_last_name_length: MAX_LAST_NAME_LENGTH,
|
||||||
max_location_length: MAX_LOCATION_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
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
use crate::data::user::UserID;
|
use crate::data::user::UserID;
|
||||||
|
|
||||||
|
pub type CommentID = u64;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Comment {
|
pub struct Comment {
|
||||||
pub id: u64,
|
pub id: CommentID,
|
||||||
pub time_sent: u64,
|
pub time_sent: u64,
|
||||||
pub user_id: UserID,
|
pub user_id: UserID,
|
||||||
pub post_id: u64,
|
pub post_id: u64,
|
||||||
|
@ -82,6 +82,7 @@ pub struct Config {
|
|||||||
pub rtc_relay: Option<RtcRelayConfig>,
|
pub rtc_relay: Option<RtcRelayConfig>,
|
||||||
pub admin_url: String,
|
pub admin_url: String,
|
||||||
pub banner: Option<Banner>,
|
pub banner: Option<Banner>,
|
||||||
|
pub allow_reporting: bool,
|
||||||
pub forez_groups: Vec<GroupID>,
|
pub forez_groups: Vec<GroupID>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +250,8 @@ impl Config {
|
|||||||
|
|
||||||
banner,
|
banner,
|
||||||
|
|
||||||
|
allow_reporting: Self::yaml_bool(parsed, "allow_reporting"),
|
||||||
|
|
||||||
forez_groups,
|
forez_groups,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -44,4 +44,5 @@ pub mod presence;
|
|||||||
pub mod admin;
|
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;
|
72
src/data/report_cause.rs
Normal file
72
src/data/report_cause.rs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
use crate::data::comment::CommentID;
|
||||||
|
use crate::data::conversation::ConvID;
|
||||||
|
use crate::data::conversation_message::ConvMessageID;
|
||||||
|
use crate::data::group_id::GroupID;
|
||||||
|
use crate::data::post::PostID;
|
||||||
|
use crate::data::user::UserID;
|
||||||
|
|
||||||
|
|
||||||
|
pub enum ReportTarget {
|
||||||
|
Post(PostID),
|
||||||
|
Comment(CommentID),
|
||||||
|
Conversation(ConvID),
|
||||||
|
ConversationMessage(ConvMessageID),
|
||||||
|
User(UserID),
|
||||||
|
Group(GroupID),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||||
|
pub struct ReportCauseId(&'static str);
|
||||||
|
|
||||||
|
impl ReportCauseId {
|
||||||
|
pub fn id(&self) -> &'static str {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ReportCause {
|
||||||
|
_id: &'static str,
|
||||||
|
pub label_fr: &'static str,
|
||||||
|
pub label_en: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const REPORT_CAUSES: [ReportCause; 5] = [
|
||||||
|
ReportCause {
|
||||||
|
_id: "spam",
|
||||||
|
label_fr: "C'est du spam",
|
||||||
|
label_en: "It is spam",
|
||||||
|
},
|
||||||
|
ReportCause {
|
||||||
|
_id: "nudity",
|
||||||
|
label_fr: "Scènes de nudité / de pornographie",
|
||||||
|
label_en: "Nudity / Sexual activity",
|
||||||
|
},
|
||||||
|
ReportCause {
|
||||||
|
_id: "violence",
|
||||||
|
label_fr: "Scènes de violence",
|
||||||
|
label_en: "Violence scenes",
|
||||||
|
},
|
||||||
|
ReportCause {
|
||||||
|
_id: "harassment",
|
||||||
|
label_fr: "Harcèlement",
|
||||||
|
label_en: "Harassment",
|
||||||
|
},
|
||||||
|
ReportCause {
|
||||||
|
_id: "other",
|
||||||
|
label_fr: "Autre",
|
||||||
|
label_en: "Other",
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
impl ReportCause {
|
||||||
|
pub fn id(&self) -> ReportCauseId {
|
||||||
|
ReportCauseId(self._id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Report {
|
||||||
|
pub user_id: UserID,
|
||||||
|
pub target: ReportTarget,
|
||||||
|
pub time: u64,
|
||||||
|
pub comment: Option<String>,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user