From bce8b332d287b45d2326cf1ad4a2b2a5aab285e5 Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Sat, 25 May 2024 12:40:58 +0200 Subject: [PATCH] irc: handle repeated joins correctly --- crates/projection-irc/src/lib.rs | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/projection-irc/src/lib.rs b/crates/projection-irc/src/lib.rs index 0bf77fb..6b4374c 100644 --- a/crates/projection-irc/src/lib.rs +++ b/crates/projection-irc/src/lib.rs @@ -894,24 +894,32 @@ async fn handle_join( match chan { Chan::Global(chan_name) => { let room_id = RoomId::from(chan_name.clone())?; - if let JoinResult::Success(room_info) = user_handle.join_room(room_id).await? { - produce_on_join_cmd_messages(&config, &user, chan, &room_info, writer).await?; - } else { - ServerMessage { - tags: vec![], - sender: Some(config.server_name.clone()), - body: ServerMessageBody::N474BannedFromChan { - client: user.nickname.clone(), - chan: chan.clone(), - message: "U dun goofed".into(), - }, + match user_handle.join_room(room_id).await? { + JoinResult::Success(room_info) => { + produce_on_join_cmd_messages(&config, &user, chan, &room_info, writer).await?; + } + JoinResult::AlreadyJoined => { + // we do nothing on repeated joins + } + JoinResult::Banned => { + ServerMessage { + tags: vec![], + sender: Some(config.server_name.clone()), + body: ServerMessageBody::N474BannedFromChan { + client: user.nickname.clone(), + chan: chan.clone(), + message: "U dun goofed".into(), + }, + } + .write_async(writer) + .await?; } - .write_async(writer) - .await?; } writer.flush().await?; } - Chan::Local(_) => {} + Chan::Local(_) => { + // TODO handle join attempts to local chans with an error, we don't support these + } }; Ok(()) }