1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-02-27 19:21:14 +00:00
comunicapiv3/src/constants.rs

120 lines
3.9 KiB
Rust
Raw Normal View History

2020-05-26 17:51:11 +02:00
//! Project constants
//!
//! This module contains all the hard-coded value that might be used everywhere in the project.
//!
//! @author Pierre Hubert
use std::time::Duration;
2020-05-26 17:51:11 +02:00
/// The name of the tables
pub mod database_tables_names {
/// API services tokens table
2021-02-13 14:37:15 +01:00
pub const CLIENTS_TABLE: &str = "comunic_clients";
2020-05-26 17:51:11 +02:00
/// User access tokens table
2021-02-13 14:37:15 +01:00
pub const USER_ACCESS_TOKENS_TABLE: &str = "comunic_user_access_tokens";
2020-05-26 17:51:11 +02:00
/// User table
pub const USERS_TABLE: &str = "utilisateurs";
/// Friends table
pub const FRIENDS_TABLE: &str = "amis";
2020-05-26 19:45:38 +02:00
/// Custom emojis table
pub const EMOJIS_TABLE: &str = "comunic_custom_emojis";
2020-06-01 10:17:32 +02:00
/// Likes table
pub const LIKES_TABLE: &str = "aime";
2020-06-03 13:28:28 +02:00
/// Groups list table
pub const GROUPS_LIST_TABLE: &str = "comunic_groups";
2020-06-04 13:36:57 +02:00
2020-06-24 09:08:31 +02:00
/// Groups members table
pub const GROUPS_MEMBERS_TABLE: &str = "comunic_groups_members";
2020-06-04 13:36:57 +02:00
/// Conversations tables
pub const CONV_LIST_TABLE: &str = "comunic_conversations_list";
pub const CONV_USERS_TABLE: &str = "comunic_conversations_users";
pub const CONV_MESSAGES_TABLE: &str = "comunic_conversations_messages";
2020-07-02 18:19:04 +02:00
/// Posts table
pub const POSTS_TABLE: &str = "texte";
2020-07-03 16:41:14 +02:00
/// Movies table
pub const MOVIES_TABLE: &str = "galerie_video";
2020-07-04 16:44:42 +02:00
/// Survey info table
pub const SURVEY_INFO_TABLE: &str = "sondage";
/// Survey choices table
pub const SURVEY_CHOICES_TABLE: &str = "sondage_choix";
/// Survey responses table
pub const SURVEY_RESPONSE_TABLE: &str = "sondage_reponse";
2020-07-05 19:32:28 +02:00
/// Comments table
pub const COMMENTS_TABLE: &str = "commentaires";
/// Notifications table
pub const NOTIFICATIONS_TABLE: &str = "comunic_notifications";
2020-05-26 18:02:14 +02:00
}
2021-02-05 10:37:37 +01:00
/// WebSocket access token lifetime, in seconds
pub const WS_ACCESS_TOKEN_LIFETIME: u64 = 10;
/// WebSocket access token length
pub const WS_ACCESS_TOKEN_LENGTH: usize = 10;
2021-01-22 19:39:14 +01:00
/// Lifetime of limit counter (1 hour)
pub const LIMIT_COUNTER_LIFETIME: u64 = 60 * 60;
2020-05-26 18:02:14 +02:00
/// The account image to show for user who do not have any
pub const DEFAULT_ACCOUNT_IMAGE: &str = "avatars/0Reverse.png";
/// The account image to show for users who are not allowed to access other users account images
2020-06-20 10:31:58 +02:00
pub const ERROR_ACCOUNT_IMAGE: &str = "avatars/0Red.png";
2020-06-26 10:53:05 +02:00
/// The path where groups logos should be stored
pub const PATH_GROUPS_LOGOS: &str = "groups_logo";
2020-06-25 08:16:20 +02:00
/// The group logo to use when no custom logo have been uploaded
pub const DEFAULT_GROUP_LOGO: &str = "groups_logo/default.png";
2020-07-08 11:03:17 +02:00
/// The path where image associated with posts should be stored
2020-07-08 17:14:55 +02:00
pub const PATH_POST_IMAGES: &str = "imgpost";
/// The path were PDF included with posts should be stored
pub const PATH_POST_PDF: &str = "post_pdf";
2020-07-08 11:03:17 +02:00
2020-07-10 08:21:40 +02:00
/// The page where comments images are stored
pub const PATH_COMMENTS_IMAGES: &str = "imgcommentaire";
2020-06-20 10:31:58 +02:00
/// Maximum requests size (50 Mo)
2020-07-10 08:21:40 +02:00
pub const MAX_REQUEST_SIZE: usize = 50000000;
2020-07-10 11:59:18 +02:00
/// Maximum number of choices per survey
pub const MAXIMUM_NUMBER_SURVEY_CHOICES: usize = 20;
/// Length of password reset token
pub const PASSWORD_RESET_TOKEN_LENGTH: usize = 255;
/// Duration of the validity of a password reset token (6 hours)
2020-07-13 18:56:36 +02:00
pub const PASSWORD_RESET_TOKEN_LIFETIME: u64 = 60 * 60 * 6;
/// Minimum password length
2020-07-14 13:33:17 +02:00
pub const PASSWORD_MIN_LENGTH: usize = 3;
/// Supported languages (for ComunicWeb)
pub const SUPPORTED_LANGUAGES: &'static [&'static str] = &["en", "fr"];
/// Interval at which last active time of user should be recorded
2021-02-13 14:37:15 +01:00
pub const USER_LAST_ACTIVITY_REFRESH: Duration = Duration::from_secs(60);
/// Interval at which last activity of an access token should be recorded
2021-02-13 16:36:39 +01:00
pub const USER_ACCESS_TOKEN_ACTIVITY_REFRESH: Duration = Duration::from_secs(60 * 60);
2021-02-14 18:54:39 +01:00
/// Sleep time before initial clean up execution
pub const INITIAL_REFRESH_LOAD_INTERVAL: Duration = Duration::from_secs(5);
2021-02-13 16:36:39 +01:00
/// Interval between each cleanup operation (every hour)
pub const CLEAN_UP_INTERVAL: Duration = Duration::from_secs(60 * 60);