50 lines
1.8 KiB
Rust
50 lines
1.8 KiB
Rust
//! Constant behavior paramenters.
|
|
|
|
use std::time::Duration;
|
|
|
|
use const_macros::{file::FileAsset, include_asset};
|
|
|
|
/// Max [`moka`] pfp cache capacity
|
|
pub const MAX_PFP_CACHE_CAPACITY: u64 = 1024;
|
|
|
|
/// Max filesize of accepted user profile pictures, to prevent huge cache and serving times
|
|
pub const MAX_PFP_SIZE: u64 = 8 * 1024 * 1024; // 8 MiB; TODO: might lower, high for prototyping
|
|
|
|
/// Default user image to use if users have none
|
|
pub const DEFAULT_USER_PFP: FileAsset = include_asset!("assets/default-pfp.png");
|
|
/// Basically [`USER_CACHES_HEADER`] but much longer for the [`DEFAULT_USER_PFP`]
|
|
pub const DEFAULT_USER_PFP_CACHES_HEADER: &str =
|
|
crate::utils::web::make_static_cache_header!(Duration::from_hours(2), Duration::from_days(1));
|
|
|
|
/// TTL for cached user information, both in server memory and http's cache-control
|
|
pub const USER_CACHES_TTL: Duration = Duration::from_mins(15);
|
|
/// TTL for cached user information in CDNs, (stale-while-revalidate), only for non-urgent info
|
|
/// (e.g. pfp's)
|
|
pub const USER_CDN_CACHES_TTL: Duration = Duration::from_hours(1);
|
|
/// Compile-time formatted string for the cache-control header of [`USER_CACHES_TTL`] and
|
|
/// [`USER_CDN_CACHES_TTL`]
|
|
pub const USER_CACHES_HEADER: &str =
|
|
crate::utils::web::make_static_cache_header!(USER_CACHES_TTL, USER_CDN_CACHES_TTL);
|
|
|
|
/// Paths relative to a user's home to search profile pictures in
|
|
pub const USER_PFP_PATHS: &[&str] = &[
|
|
".config/logo.avif",
|
|
".config/logo.webp",
|
|
".config/logo.png",
|
|
".config/logo.jpg",
|
|
"logo.png",
|
|
"logo.jpg",
|
|
".face",
|
|
];
|
|
|
|
pub const ERROR_ASCII_ARTS: &[&str] = &[
|
|
include_str!("../assets/lain/lain-dancing.txt"),
|
|
include_str!("../assets/lain/lain-head.txt"),
|
|
include_str!("../assets/lain/lain-teddy-head.txt"),
|
|
include_str!("../assets/lain/lain-teddy.txt"),
|
|
];
|
|
|
|
pub mod web_scopes {
|
|
pub const IMAGES: &str = "/image";
|
|
}
|