fixes-16
This commit is contained in:
parent
f693a8418e
commit
fd22aeb518
15
src/main.rs
15
src/main.rs
|
@ -87,8 +87,6 @@ async fn create_first_chat(author_id: i32, con: &mut redis::aio::Connection) ->
|
|||
Ok(vec![chat.to_string()])
|
||||
}
|
||||
|
||||
// Функция проверяет токен пользователя, получает список чатов пользователя из Redis
|
||||
// и подписывается на события этих чатов. Если у пользователя нет чатов, создается первый чат.
|
||||
async fn sse_handler(
|
||||
token: web::Path<String>,
|
||||
mut rx: web::Data<Receiver<String>>,
|
||||
|
@ -110,7 +108,7 @@ async fn sse_handler(
|
|||
}
|
||||
};
|
||||
|
||||
let _: () = match con.command("SADD", "authors-online", &author_id).await {
|
||||
let _: () = match con.sadd("authors-online", &author_id).await {
|
||||
Ok(_) => (),
|
||||
Err(e) => {
|
||||
eprintln!("Failed to add author to online list: {}", e);
|
||||
|
@ -135,12 +133,12 @@ async fn sse_handler(
|
|||
Err(e) => {
|
||||
eprintln!("Failed to get chats by author: {}", e);
|
||||
match create_first_chat(author_id, &mut con).await {
|
||||
Ok(chat) => chat,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to create first chat: {}", e);
|
||||
return HttpResponse::InternalServerError().finish();
|
||||
}
|
||||
Ok(chat) => chat,
|
||||
Err(e) => {
|
||||
eprintln!("Failed to create first chat: {}", e);
|
||||
return HttpResponse::InternalServerError().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -160,7 +158,6 @@ async fn sse_handler(
|
|||
}
|
||||
};
|
||||
|
||||
// Later in the sse_handler function
|
||||
let server_event = match rx.recv().await {
|
||||
Ok(event) => event,
|
||||
Err(e) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user