Fix group messages: push via WebSocket, not just DB queue
Group send_to_group was writing directly to sled DB, bypassing the WS push. Connected clients never received group messages. Now tries push_to_client() first (instant WS delivery), falls back to DB queue if recipient is offline. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -184,8 +184,13 @@ async fn send_to_group(
|
||||
for msg in &req.messages {
|
||||
let to = normalize_fp(&msg.to);
|
||||
if group.members.contains(&to) {
|
||||
// Try WebSocket push first (instant), fall back to DB queue
|
||||
if state.push_to_client(&to, &msg.message).await {
|
||||
tracing::debug!("Group '{}': pushed to {} via WS", name, to);
|
||||
} else {
|
||||
let key = format!("queue:{}:{}", to, uuid::Uuid::new_v4());
|
||||
state.db.messages.insert(key.as_bytes(), msg.message.as_slice())?;
|
||||
}
|
||||
delivered += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user