use std::path::{Path, PathBuf};
use uuid::Uuid;
use crate::constants::{CRON, KEYS, MAILBOX};
use crate::home::UnifierHome;
pub fn cron_dir(home: &UnifierHome, schedule: &str) -> PathBuf {
home.path().join(CRON).join(schedule)
}
pub fn mailbox_dir(home: &UnifierHome, recipient: &str) -> PathBuf {
home.path().join(MAILBOX).join(recipient)
}
pub fn key_path(home: &UnifierHome, key: &str) -> PathBuf {
home.path().join(KEYS).join(key)
}
pub fn message_path(dir: &Path, id: &Uuid) -> PathBuf {
dir.join(format!("{}.txt", id.hyphenated()))
}
pub fn parse_message_id(filename: &str) -> Option<Uuid> {
let stem = filename.strip_suffix(".txt")?;
Uuid::parse_str(stem).ok()
}