//! Helpers for translating domain events into WebSocket server events.

use athena_chat::events::ChatEventEnvelope;
use athena_chat::ids::{RoomId, UserId};

use crate::protocol::{ServerWsEvent, server_event_from_chat_event};

/// Delegates to [`crate::protocol::server_event_from_chat_event`].
pub fn map_chat_event(event: &ChatEventEnvelope) -> Option<ServerWsEvent> {
    server_event_from_chat_event(event)
}

/// Builds a `chat.typing.updated` event (`ChatWsTypingUpdatedEvent`) for room broadcast.
pub fn typing_event(room_id: RoomId, user_id: UserId, state: &str) -> ServerWsEvent {
    ServerWsEvent::ChatTypingUpdated {
        room_id,
        user_id,
        state: state.to_string(),
    }
}
