use super::syntax::SyntaxDetails;
use serde::Serialize;
const ROLE_ACCOUNTS: &str = include_str!("./util/roles.json");
#[derive(Debug, Serialize)]
pub struct MiscDetails {
pub is_disposable: bool,
pub is_role_account: bool,
}
impl Default for MiscDetails {
fn default() -> Self {
MiscDetails {
is_disposable: false,
is_role_account: false,
}
}
}
#[derive(Debug, Serialize)]
#[serde(tag = "type", content = "message")]
pub enum MiscError {}
pub fn check_misc(syntax: &SyntaxDetails) -> MiscDetails {
let role_accounts: Vec<&str> =
serde_json::from_str(ROLE_ACCOUNTS).expect("roles.json is a valid json. qed.");
MiscDetails {
is_disposable: !mailchecker::is_valid(
syntax
.address
.as_ref()
.expect("We already checked that the syntax was valid. qed.")
.to_string()
.as_ref(),
),
is_role_account: role_accounts.contains(&syntax.username.to_lowercase().as_ref()),
}
}