Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed Messages #599

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/server/src/events/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ async fn push_events(mailbox: Uuid, outgoing: &mut Sender, after: Option<i64>, s
let cached_events = Event::get_from_cache(&mailbox, after, seq).await;
if !cached_events.is_empty() {
use itertools::Itertools;
let messages: Vec<Result<String, serde_json::Error>> = cached_events
let payload_list: Vec<Result<String, serde_json::Error>> = cached_events
.into_iter()
.chunks(CHUNK_SIZE)
.into_iter()
.map(|events| Event::batch(mailbox, events.collect()))
.map(|batch_event| serde_json::to_string(&batch_event))
.collect();
for message in messages {
let Ok(message) = message else {
for payload in payload_list {
let Ok(payload) = payload else {
log::warn!("Failed to serialize batch event to mailbox {}", mailbox);
return;
};
if let Err(err) = tx.send(WsMessage::Text(message)).await {
if let Err(err) = tx.send(WsMessage::Text(payload)).await {
log::warn!("Failed to send batch event to mailbox {}: {}", mailbox, err);
return;
};
Expand Down