pub mod actor;
pub mod deliver;
pub mod discover;
pub mod inbox;
pub mod keys;
pub mod nodeinfo;
pub mod outbox;
pub mod signatures;
pub mod types;

use std::sync::atomic::{AtomicBool, Ordering};

static FEDERATION_FROZEN: AtomicBool = AtomicBool::new(false);

pub fn is_frozen() -> bool {
    FEDERATION_FROZEN.load(Ordering::Acquire)
}

pub fn set_frozen(frozen: bool) {
    FEDERATION_FROZEN.store(frozen, Ordering::Release);
}

pub struct ApState {
    pub domain: String,
    pub actor_name: String,
    pub actor_uri: String,
    pub keys: keys::ApKeys,
}

impl ApState {
    pub fn new(domain: String, actor_name: String, keys: keys::ApKeys) -> Self {
        let actor_uri = format!("https://{}/@{}", domain, actor_name);
        Self { domain, actor_name, actor_uri, keys }
    }
}
