//! Authorization helpers shared by [`crate::repo::traits::ChatRepository`] implementations.

use crate::error::{ChatError, ChatResult};

/// Returns `Ok(())` when `condition` is true; otherwise [`ChatError::Forbidden`].
pub fn ensure(condition: bool, message: impl Into<String>) -> ChatResult<()> {
    if condition {
        Ok(())
    } else {
        Err(ChatError::Forbidden(message.into()))
    }
}
