diff --git a/src/main.rs b/src/main.rs index f1aa762..4eab453 100644 --- a/src/main.rs +++ b/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, mut rx: web::Data>, @@ -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) => {