fixes-23
This commit is contained in:
parent
1f3019ea1a
commit
9e181fe303
13
src/main.rs
13
src/main.rs
|
@ -10,7 +10,6 @@ use futures::StreamExt;
|
||||||
use tokio::sync::broadcast::{self, Receiver};
|
use tokio::sync::broadcast::{self, Receiver};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
|
@ -83,7 +82,7 @@ async fn create_first_chat(author_id: i32, con: &mut redis::aio::Connection) ->
|
||||||
.query_async(con)
|
.query_async(con)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(vec![chat.to_string()])
|
Ok(vec![chat_id, ])
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn sse_handler(
|
async fn sse_handler(
|
||||||
|
@ -142,14 +141,12 @@ async fn sse_handler(
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut pubsub = con.into_pubsub();
|
let mut pubsub = con.into_pubsub();
|
||||||
|
for chat_id in &chats {
|
||||||
let mut con = match redis.get_async_connection().await {
|
if let Err(e) = pubsub.subscribe(format!("chat:{}", chat_id)).await {
|
||||||
Ok(con) => con,
|
eprintln!("Failed to subscribe to chat: {}", e);
|
||||||
Err(e) => {
|
|
||||||
eprintln!("Failed to get async connection: {}", e);
|
|
||||||
return HttpResponse::InternalServerError().finish();
|
return HttpResponse::InternalServerError().finish();
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
let _ = match con.srem::<&str, &i32, usize>("authors-online", &author_id).await {
|
let _ = match con.srem::<&str, &i32, usize>("authors-online", &author_id).await {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user