mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Move pre-kick checks from core to cmd_kick (core_channel)
This commit is contained in:
parent
53c59d9a99
commit
bef2d3f462
@ -448,45 +448,6 @@ void Channel::KickUser(User* src, User* victim, const std::string& reason, Membe
|
||||
{
|
||||
UserMembIter victimiter = userlist.find(victim);
|
||||
Membership* memb = ((victimiter != userlist.end()) ? victimiter->second : NULL);
|
||||
|
||||
if (!memb)
|
||||
{
|
||||
src->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", victim->nick.c_str(), this->name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
// Do the following checks only if the KICK is done by a local user;
|
||||
// each server enforces its own rules.
|
||||
if (IS_LOCAL(src))
|
||||
{
|
||||
// Modules are allowed to explicitly allow or deny kicks done by local users
|
||||
ModResult res;
|
||||
FIRST_MOD_RESULT(OnUserPreKick, res, (src,memb,reason));
|
||||
if (res == MOD_RES_DENY)
|
||||
return;
|
||||
|
||||
if (res == MOD_RES_PASSTHRU)
|
||||
{
|
||||
if (!srcmemb)
|
||||
srcmemb = GetUser(src);
|
||||
unsigned int them = srcmemb ? srcmemb->getRank() : 0;
|
||||
unsigned int req = HALFOP_VALUE;
|
||||
for (std::string::size_type i = 0; i < memb->modes.length(); i++)
|
||||
{
|
||||
ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
|
||||
if (mh && mh->GetLevelRequired() > req)
|
||||
req = mh->GetLevelRequired();
|
||||
}
|
||||
|
||||
if (them < req)
|
||||
{
|
||||
src->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
|
||||
this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CUList except_list;
|
||||
FOREACH_MOD(OnUserKick, (src, memb, reason, except_list));
|
||||
|
||||
|
@ -66,6 +66,13 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
|
||||
}
|
||||
}
|
||||
|
||||
Membership* const memb = c->GetUser(u);
|
||||
if (!memb)
|
||||
{
|
||||
user->WriteNumeric(ERR_USERNOTINCHANNEL, "%s %s :They are not on that channel", u->nick.c_str(), c->name.c_str());
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
if (parameters.size() > 2)
|
||||
{
|
||||
reason.assign(parameters[2], 0, ServerInstance->Config->Limits.MaxKick);
|
||||
@ -75,6 +82,36 @@ CmdResult CommandKick::Handle (const std::vector<std::string>& parameters, User
|
||||
reason.assign(user->nick, 0, ServerInstance->Config->Limits.MaxKick);
|
||||
}
|
||||
|
||||
// Do the following checks only if the KICK is done by a local user;
|
||||
// each server enforces its own rules.
|
||||
if (srcmemb)
|
||||
{
|
||||
// Modules are allowed to explicitly allow or deny kicks done by local users
|
||||
ModResult res;
|
||||
FIRST_MOD_RESULT(OnUserPreKick, res, (user, memb, reason));
|
||||
if (res == MOD_RES_DENY)
|
||||
return CMD_FAILURE;
|
||||
|
||||
if (res == MOD_RES_PASSTHRU)
|
||||
{
|
||||
unsigned int them = srcmemb->getRank();
|
||||
unsigned int req = HALFOP_VALUE;
|
||||
for (std::string::size_type i = 0; i < memb->modes.length(); i++)
|
||||
{
|
||||
ModeHandler* mh = ServerInstance->Modes->FindMode(memb->modes[i], MODETYPE_CHANNEL);
|
||||
if (mh && mh->GetLevelRequired() > req)
|
||||
req = mh->GetLevelRequired();
|
||||
}
|
||||
|
||||
if (them < req)
|
||||
{
|
||||
user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s :You must be a channel %soperator",
|
||||
this->name.c_str(), req > HALFOP_VALUE ? "" : "half-");
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c->KickUser(user, u, reason, srcmemb);
|
||||
|
||||
return CMD_SUCCESS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user