diff --git a/src/commands/QuitCommand.cpp b/src/commands/QuitCommand.cpp index 02f8bf3..e3d8eda 100644 --- a/src/commands/QuitCommand.cpp +++ b/src/commands/QuitCommand.cpp @@ -27,6 +27,9 @@ void QuitCommand::execute(int clientFd) { std::set allUsers; std::set::iterator it; + + if (user.isRegistered()) + allUsers.insert(user); for (size_t i = 0; i < channels.size(); i++) { if (!channels[i].isUserInChannel(nickname)) continue; @@ -37,14 +40,10 @@ void QuitCommand::execute(int clientFd) { usersChannel.clear(); } - if (allUsers.empty() && user.isRegistered()) - allUsers.insert(user); - for (it = allUsers.begin(); it != allUsers.end(); it++) { server.sendMessage(it->getFd(), QUIT_MSG(nickname, user.getUsername(), user.getHostname(), _message.empty() ? nickname : _message)); } - server.handleClientDisconnection(clientFd); } \ No newline at end of file