feat(room): add TypingEvent type and TypingStart/TypingStop event variants
Add TypingEvent struct in queue::types for broadcast-based typing indicators, and TypingStart/TypingStop variants in RoomEventType for WebSocket event dispatch.
This commit is contained in:
parent
22b5eab769
commit
e83512382f
@ -7,7 +7,7 @@ pub mod worker;
|
||||
pub use producer::{MessageProducer, RedisPubSub};
|
||||
pub use types::{
|
||||
AgentTaskEvent, EmailEnvelope, ProjectRoomEvent, ReactionGroup, RoomMessageEnvelope,
|
||||
RoomMessageEvent, RoomMessageStreamChunkEvent,
|
||||
RoomMessageEvent, RoomMessageStreamChunkEvent, TypingEvent,
|
||||
};
|
||||
pub use worker::{
|
||||
room_worker_task, start as start_worker, start_email_worker, EmailSendFn, EmailSendFut, GetRedis,
|
||||
|
||||
@ -42,6 +42,17 @@ pub struct RoomMessageEvent {
|
||||
pub message_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
/// Typing indicator event — broadcast to all room members.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TypingEvent {
|
||||
pub room_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub username: String,
|
||||
pub avatar_url: Option<String>,
|
||||
/// "start" or "stop"
|
||||
pub action: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReactionGroup {
|
||||
pub emoji: String,
|
||||
|
||||
@ -33,6 +33,8 @@ pub enum RoomEventType {
|
||||
ReadReceipt,
|
||||
ReactionAdded,
|
||||
ReactionRemoved,
|
||||
TypingStart,
|
||||
TypingStop,
|
||||
}
|
||||
|
||||
impl RoomEventType {
|
||||
@ -55,6 +57,8 @@ impl RoomEventType {
|
||||
RoomEventType::ReadReceipt => "read_receipt",
|
||||
RoomEventType::ReactionAdded => "reaction_added",
|
||||
RoomEventType::ReactionRemoved => "reaction_removed",
|
||||
RoomEventType::TypingStart => "typing_start",
|
||||
RoomEventType::TypingStop => "typing_stop",
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +81,8 @@ impl RoomEventType {
|
||||
"read_receipt" => Some(RoomEventType::ReadReceipt),
|
||||
"reaction_added" => Some(RoomEventType::ReactionAdded),
|
||||
"reaction_removed" => Some(RoomEventType::ReactionRemoved),
|
||||
"typing_start" => Some(RoomEventType::TypingStart),
|
||||
"typing_stop" => Some(RoomEventType::TypingStop),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user