feat: add image fetching

This commit is contained in:
2026-03-20 19:48:18 +01:00
parent fb62111c7f
commit 12388a9908
17 changed files with 2122 additions and 92 deletions

27
src/consts.rs Normal file
View File

@@ -0,0 +1,27 @@
//! Constant behavior paramenters.
use std::time::Duration;
/// 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: &[u8] = include_bytes!("../assets/default-pfp.png");
pub const DEFAULT_USER_PFP_MIME: &str = "image/png; charset=binary";
/// TTL for cached user information
pub const USER_CACHES_TTL: Duration = Duration::from_mins(15);
/// 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",
];