summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-06-02 19:30:55 +0200
committerattilamolnar <attilamolnar@hush.com>2013-06-04 01:57:35 +0200
commit6db924458501457768d7ddafd5de8a69839f6399 (patch)
treeb0e19da0e086074efcf5b479e44a6ac8201f0823 /src
parent3a01b55a118d4937b75541fbf385180f7106fa12 (diff)
Channel::KickUser() and cmd_kick changes
- Remove uline checks from KickUser() - Disallow the kick if done by a local user and the victim is ulined in cmd_kick - Remove call to RemoveAllPrefixes() as it has no additional effect, the Membership object containing the prefixes is destroyed soon after the call
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp42
-rw-r--r--src/commands/cmd_kick.cpp15
2 files changed, 26 insertions, 31 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index 91f9b8072..2807249c1 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -502,28 +502,19 @@ void Channel::PartUser(User *user, std::string &reason)
this->DelUser(user);
}
-void Channel::KickUser(User *src, User *user, const std::string& reason)
+void Channel::KickUser(User* src, User* victim, const std::string& reason)
{
- Membership* memb = GetUser(user);
- if (IS_LOCAL(src))
+ Membership* memb = GetUser(victim);
+ if (!memb)
{
- if (!memb)
- {
- src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s %s :They are not on that channel",src->nick.c_str(), user->nick.c_str(), this->name.c_str());
- return;
- }
- if ((ServerInstance->ULine(user->server)) && (!ServerInstance->ULine(src->server)))
- {
- src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only a u-line may kick a u-line from a channel.",src->nick.c_str(), this->name.c_str());
- return;
- }
+ src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s %s :They are not on that channel",src->nick.c_str(), victim->nick.c_str(), this->name.c_str());
+ return;
+ }
+ if (IS_LOCAL(src))
+ {
ModResult res;
- if (ServerInstance->ULine(src->server))
- res = MOD_RES_ALLOW;
- else
- FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
-
+ FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
if (res == MOD_RES_DENY)
return;
@@ -547,18 +538,13 @@ void Channel::KickUser(User *src, User *user, const std::string& reason)
}
}
- if (memb)
- {
- CUList except_list;
- FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
-
- WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), user->nick.c_str(), reason.c_str());
+ CUList except_list;
+ FOREACH_MOD(I_OnUserKick,OnUserKick(src, memb, reason, except_list));
- user->chans.erase(this);
- this->RemoveAllPrefixes(user);
- }
+ WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), victim->nick.c_str(), reason.c_str());
- this->DelUser(user);
+ victim->chans.erase(this);
+ this->DelUser(victim);
}
void Channel::WriteChannel(User* user, const char* text, ...)
diff --git a/src/commands/cmd_kick.cpp b/src/commands/cmd_kick.cpp
index 87ee1da6d..ecbdbad1e 100644
--- a/src/commands/cmd_kick.cpp
+++ b/src/commands/cmd_kick.cpp
@@ -62,10 +62,19 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
return CMD_FAILURE;
}
- if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server)))
+ if (IS_LOCAL(user))
{
- user->WriteServ( "442 %s %s :You're not on that channel!", user->nick.c_str(), parameters[0].c_str());
- return CMD_FAILURE;
+ if (!c->HasUser(user))
+ {
+ user->WriteServ( "442 %s %s :You're not on that channel!", user->nick.c_str(), parameters[0].c_str());
+ return CMD_FAILURE;
+ }
+
+ if (ServerInstance->ULine(u->server))
+ {
+ user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You may not kick a u-lined client", user->nick.c_str(), c->name.c_str());
+ return CMD_FAILURE;
+ }
}
if (parameters.size() > 2)