X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fchannels.cpp;h=f49d359cd27f778c4a599948e51265ee05a7d0ea;hb=3a921efb0bd049eb8cccfcc205ebb260c78b423a;hp=a98b4ff87c702062086b5ca9b22a61e115376ec9;hpb=5ebb49de65a3f53730177665b5922dc3a62a94eb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/channels.cpp b/src/channels.cpp index a98b4ff87..f49d359cd 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -25,8 +25,6 @@ #include "inspircd.h" #include "listmode.h" -#include -#include "mode.h" namespace { @@ -292,17 +290,17 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co return chan; } -void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, bool created_by_local) +Membership* Channel::ForceJoin(User* user, const std::string* privs, bool bursting, bool created_by_local) { if (IS_SERVER(user)) { ServerInstance->Logs->Log("CHANNELS", LOG_DEBUG, "Attempted to join server user " + user->uuid + " to channel " + this->name); - return; + return NULL; } Membership* memb = this->AddUser(user); if (!memb) - return; // Already on the channel + return NULL; // Already on the channel user->chans.push_front(memb); @@ -350,6 +348,7 @@ void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, boo } FOREACH_MOD(OnPostJoin, (memb)); + return memb; } bool Channel::IsBanned(User* user) @@ -444,52 +443,13 @@ void Channel::PartUser(User *user, std::string &reason) } } -void Channel::KickUser(User* src, User* victim, const std::string& reason, Membership* srcmemb) +void Channel::KickUser(User* src, const UserMembIter& victimiter, const std::string& reason) { - 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; - } - } - } - + Membership* memb = victimiter->second; CUList except_list; FOREACH_MOD(OnUserKick, (src, memb, reason, except_list)); + User* victim = memb->user; WriteAllExcept(src, false, 0, except_list, "KICK %s %s :%s", name.c_str(), victim->nick.c_str(), reason.c_str()); victim->chans.erase(memb); @@ -785,8 +745,6 @@ void Invitation::Create(Channel* c, LocalUser* u, time_t timeout) Invitation* Invitation::Find(Channel* c, LocalUser* u, bool check_expired) { ServerInstance->Logs->Log("INVITATION", LOG_DEBUG, "Invitation::Find chan=%s user=%s check_expired=%d", c ? c->name.c_str() : "NULL", u ? u->uuid.c_str() : "NULL", check_expired); - if (!u || u->invites.empty()) - return NULL; Invitation* result = NULL; for (InviteList::iterator i = u->invites.begin(); i != u->invites.end(); )