From 94366285f279b064f3d237f7080068add82a0900 Mon Sep 17 00:00:00 2001 From: Alejandro Ruzafa Date: Thu, 28 Mar 2024 11:09:46 +0100 Subject: [PATCH] refactor: apply PR suggestions --- includes/libsUtils.hpp | 2 ++ src/Server.cpp | 7 ++++--- src/commands/InviteCommand.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/libsUtils.hpp b/includes/libsUtils.hpp index df52849..4650ca0 100644 --- a/includes/libsUtils.hpp +++ b/includes/libsUtils.hpp @@ -42,6 +42,8 @@ # define USER_NOT_FOUND_ERR "[ERROR] User not found in list." # define CHANNEL_ALREADY_ADDED_ERR "[ERROR] Channel already added." +# define INVITE_CMD_RESPONSE(nickname, channelName) nickname + " " + channelName + std::string trim(const std::string& str); std::vector split(const std::string &s, char delim); diff --git a/src/Server.cpp b/src/Server.cpp index 9caf9f2..14194c5 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -259,9 +259,10 @@ bool Server::isNicknameInUse(const std::string& nickname) const { * This function aims to get all the user information searching by the nickname. * * @param nickname The nickname of the user. - * @return The user object with all its information. * * @throws `ServerException` if the user is not found. + * + * @return The user object with all its information. */ User &Server::getUserByNickname(const std::string &nickname) { std::vector::iterator it = this->findUserByNickname(nickname); @@ -433,9 +434,9 @@ void Server::removeChannel(std::string channelName) { * * @param channelName The name of the channel. * - * @return The channel with the name. - * * @throws `ServerException` if the channel is not found. + * + * @return The channel with the name. */ Channel &Server::getChannelByName(const std::string &channelName) { std::vector::iterator it = findChannel(channelName); diff --git a/src/commands/InviteCommand.cpp b/src/commands/InviteCommand.cpp index 0fb8d0b..05717b3 100644 --- a/src/commands/InviteCommand.cpp +++ b/src/commands/InviteCommand.cpp @@ -42,5 +42,5 @@ void InviteCommand::execute(int clientFd) { if (channel.getModes() == "i" && !channel.isOper(me.getNickname())) throw ChanOPrivsNeededException(this->_channelName); channel.inviteUser(this->_nickname); - server.sendMessage(clientFd, this->_nickname + " " + this->_channelName); + server.sendMessage(clientFd, INVITE_CMD_RESPONSE(this->_nickname, this->_channelName)); } \ No newline at end of file