use crate::ui::prelude::*;

pub fn admin_filter_async() -> UpdateHandler<Box<dyn std::error::Error + Send + Sync + 'static>> {
    dptree::filter_async(|update: Update| async move {
        let is_admin = match update.from() {
            Some(user) => {
                (api::is_admin(user.id.0 as i64).await).unwrap_or(false)
            }
            None => false,
        };

        log::trace!("{}", format!("schema: admin: is_admin: {}", is_admin).bright_black());
        is_admin
    })
}