Skip to content

Commit

Permalink
Merge pull request #132 from jdomingu98/124-mode-bug-quitar-operador
Browse files Browse the repository at this point in the history
fix(mode): refactor makeOperAnUser function
  • Loading branch information
jdomingu98 authored Apr 25, 2024
2 parents ae9faf3 + f2c09fd commit ac601b6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,10 @@ bool Channel::isUserInChannel(const std::string &nickname) const {
*/
void Channel::makeUserAnOper(std::string nickname) {
std::vector<User>::iterator it = findUser(nickname);
if (it != this->_users.end()) {
this->_operators.push_back(*it);
this->_users.erase(it);
} else
if (it == this->_users.end())
throw UserNotInChannelException(nickname, this->_name);
this->_operators.push_back(*it);
this->_users.erase(it);
}

/**
Expand All @@ -352,12 +351,10 @@ void Channel::makeUserAnOper(std::string nickname) {
*/
void Channel::makeOperAnUser(std::string nickname) {
std::vector<User>::iterator it = findOper(nickname);
if (it != this->_operators.end()) {
it->setNickname(it->getNickname().substr(1));
this->_users.push_back(*it);
this->_operators.erase(it);
} else
if (it == this->_operators.end())
throw UserNotInChannelException(nickname, this->_name);
this->_users.push_back(*it);
this->_operators.erase(it);
}

/**
Expand Down

0 comments on commit ac601b6

Please sign in to comment.