mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Move FindNick to UserManager.
This commit is contained in:
parent
1cdffcaad7
commit
61070d4894
@ -339,13 +339,6 @@ class CoreExport InspIRCd
|
||||
*/
|
||||
size_t BindPorts(FailedPortList &failed_ports);
|
||||
|
||||
/** Find a user in the nick hash.
|
||||
* If the user cant be found in the nick hash check the uuid hash
|
||||
* @param nick The nickname to find
|
||||
* @return A pointer to the user, or NULL if the user does not exist
|
||||
*/
|
||||
User* FindNick(const std::string &nick);
|
||||
|
||||
/** Find a user in the nick hash ONLY
|
||||
*/
|
||||
User* FindNickOnly(const std::string &nick);
|
||||
|
@ -192,6 +192,13 @@ class CoreExport UserManager
|
||||
*/
|
||||
already_sent_t NextAlreadySentId();
|
||||
|
||||
/** Find a user by their nickname or UUID.
|
||||
* IMPORTANT: You probably want to use FindNick or FindUUID instead of this.
|
||||
* @param nickuuid The nickname or UUID of the user to find.
|
||||
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
|
||||
*/
|
||||
User* Find(const std::string& nickuuid);
|
||||
|
||||
/** Find a user by their UUID.
|
||||
* @param uuid The UUID of the user to find.
|
||||
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
|
||||
|
@ -425,7 +425,7 @@ void CommandParser::TranslateSingleParam(TranslateType to, const std::string& it
|
||||
case TR_NICK:
|
||||
{
|
||||
/* Translate single nickname */
|
||||
User* user = ServerInstance->FindNick(item);
|
||||
User* user = ServerInstance->Users.Find(item);
|
||||
if (user)
|
||||
dest.append(user->uuid);
|
||||
else
|
||||
|
@ -51,7 +51,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters)
|
||||
if (IS_LOCAL(user))
|
||||
u = ServerInstance->FindNickOnly(parameters[0]);
|
||||
else
|
||||
u = ServerInstance->FindNick(parameters[0]);
|
||||
u = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
Channel* c = ServerInstance->FindChan(parameters[1]);
|
||||
time_t timeout = 0;
|
||||
|
@ -48,7 +48,7 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters)
|
||||
if (IS_LOCAL(user))
|
||||
u = ServerInstance->FindNickOnly(parameters[1]);
|
||||
else
|
||||
u = ServerInstance->FindNick(parameters[1]);
|
||||
u = ServerInstance->Users.Find(parameters[1]);
|
||||
|
||||
if (!c)
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ class CommandMessage : public Command
|
||||
else
|
||||
{
|
||||
// Remote users can only specify a nick or UUID as the target.
|
||||
target = ServerInstance->FindNick(parameters[0]);
|
||||
target = ServerInstance->Users.Find(parameters[0]);
|
||||
}
|
||||
|
||||
if (!target || target->registered != REG_ALL)
|
||||
|
@ -91,7 +91,7 @@ CmdResult CommandMode::Handle(User* user, const Params& parameters)
|
||||
if (IS_LOCAL(user))
|
||||
targetuser = ServerInstance->FindNickOnly(target);
|
||||
else
|
||||
targetuser = ServerInstance->FindNick(target);
|
||||
targetuser = ServerInstance->Users.Find(target);
|
||||
}
|
||||
|
||||
if ((!targetchannel || !CanSeeChan(user, targetchannel)) && (!targetuser))
|
||||
|
@ -65,7 +65,7 @@ CmdResult CommandKill::Handle(User* user, const Params& parameters)
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
User* target = ServerInstance->FindNick(parameters[0]);
|
||||
User* target = ServerInstance->Users.Find(parameters[0]);
|
||||
if (!target)
|
||||
{
|
||||
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
|
||||
|
@ -45,7 +45,7 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters)
|
||||
if (parameters.size() >= 3)
|
||||
{
|
||||
IdentHostPair ih;
|
||||
User* find = ServerInstance->FindNick(target);
|
||||
User* find = ServerInstance->Users.Find(target);
|
||||
if ((find) && (find->registered == REG_ALL))
|
||||
{
|
||||
ih.first = "*";
|
||||
|
@ -46,7 +46,7 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters)
|
||||
if (parameters.size() >= 3)
|
||||
{
|
||||
IdentHostPair ih;
|
||||
User* find = ServerInstance->FindNick(target);
|
||||
User* find = ServerInstance->Users.Find(target);
|
||||
if ((find) && (find->registered == REG_ALL))
|
||||
{
|
||||
ih.first = "*";
|
||||
|
@ -46,7 +46,7 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters)
|
||||
if (parameters.size() >= 3)
|
||||
{
|
||||
IdentHostPair ih;
|
||||
User* find = ServerInstance->FindNick(target);
|
||||
User* find = ServerInstance->Users.Find(target);
|
||||
if ((find) && (find->registered == REG_ALL))
|
||||
{
|
||||
ih.first = "*";
|
||||
|
@ -50,7 +50,7 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters)
|
||||
return CMD_FAILURE;
|
||||
}
|
||||
|
||||
User *u = ServerInstance->FindNick(target);
|
||||
User *u = ServerInstance->Users.Find(target);
|
||||
|
||||
if ((u) && (u->registered == REG_ALL))
|
||||
{
|
||||
|
@ -39,13 +39,6 @@
|
||||
#include <iostream>
|
||||
|
||||
/* Find a user record by nickname and return a pointer to it */
|
||||
User* InspIRCd::FindNick(const std::string &nick)
|
||||
{
|
||||
if (!nick.empty() && isdigit(*nick.begin()))
|
||||
return FindUUID(nick);
|
||||
return FindNickOnly(nick);
|
||||
}
|
||||
|
||||
User* InspIRCd::FindNickOnly(const std::string &nick)
|
||||
{
|
||||
user_hash::iterator iter = this->Users.clientlist.find(nick);
|
||||
|
@ -190,7 +190,7 @@ ModeAction PrefixMode::OnModeChange(User* source, User*, Channel* chan, std::str
|
||||
if (IS_LOCAL(source))
|
||||
target = ServerInstance->FindNickOnly(parameter);
|
||||
else
|
||||
target = ServerInstance->FindNick(parameter);
|
||||
target = ServerInstance->Users.Find(parameter);
|
||||
|
||||
if (!target)
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ struct CallerIDExtInfo : public ExtensionItem
|
||||
|
||||
while (s.GetToken(tok))
|
||||
{
|
||||
User *u = ServerInstance->FindNick(tok);
|
||||
User *u = ServerInstance->Users.Find(tok);
|
||||
if ((u) && (u->registered == REG_ALL) && (!u->quitting))
|
||||
{
|
||||
if (dat->accepting.insert(u).second)
|
||||
@ -166,7 +166,7 @@ class CommandAccept : public Command
|
||||
|
||||
User* target;
|
||||
if (!cmdfrom || !IS_LOCAL(cmdfrom))
|
||||
target = ServerInstance->FindNick(tok);
|
||||
target = ServerInstance->Users.Find(tok);
|
||||
else
|
||||
target = ServerInstance->FindNickOnly(tok);
|
||||
|
||||
|
@ -162,7 +162,7 @@ class CommandCheck : public Command
|
||||
Channel *targchan;
|
||||
std::string chliststr;
|
||||
|
||||
targuser = ServerInstance->FindNick(parameters[0]);
|
||||
targuser = ServerInstance->Users.Find(parameters[0]);
|
||||
targchan = ServerInstance->FindChan(parameters[0]);
|
||||
|
||||
/*
|
||||
|
@ -58,7 +58,7 @@ class CommandChghost : public Command
|
||||
}
|
||||
}
|
||||
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
// Allow services to change the host of unregistered users
|
||||
if ((!dest) || ((dest->registered != REG_ALL) && (!user->server->IsULine())))
|
||||
|
@ -42,7 +42,7 @@ class CommandChgident : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if ((!dest) || (dest->registered != REG_ALL))
|
||||
{
|
||||
|
@ -41,7 +41,7 @@ class CommandChgname : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if ((!dest) || (dest->registered != REG_ALL))
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ ModResult ModuleDelayJoin::OnRawMode(User* user, Channel* channel, ModeHandler*
|
||||
if (IS_LOCAL(user))
|
||||
dest = ServerInstance->FindNickOnly(param);
|
||||
else
|
||||
dest = ServerInstance->FindNick(param);
|
||||
dest = ServerInstance->Users.Find(param);
|
||||
|
||||
if (!dest)
|
||||
return MOD_RES_PASSTHRU;
|
||||
|
@ -172,7 +172,7 @@ class CommandTagMsg : public Command
|
||||
else
|
||||
{
|
||||
// Remote users can only specify a nick or UUID as the target.
|
||||
target = ServerInstance->FindNick(parameters[0]);
|
||||
target = ServerInstance->Users.Find(parameters[0]);
|
||||
}
|
||||
|
||||
if (!target || target->registered != REG_ALL)
|
||||
|
@ -50,7 +50,7 @@ class CommandNicklock : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* target = ServerInstance->FindNick(parameters[0]);
|
||||
User* target = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if ((!target) || (target->registered != REG_ALL))
|
||||
{
|
||||
@ -110,7 +110,7 @@ class CommandNickunlock : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* target = ServerInstance->FindNick(parameters[0]);
|
||||
User* target = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if (!target)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ class NetworkPrefix : public PrefixMode
|
||||
|
||||
ModResult AccessCheck(User* source, Channel* channel, std::string ¶meter, bool adding) override
|
||||
{
|
||||
User* theuser = ServerInstance->FindNick(parameter);
|
||||
User* theuser = ServerInstance->Users.Find(parameter);
|
||||
// remove own privs?
|
||||
if (source == theuser && !adding)
|
||||
return MOD_RES_ALLOW;
|
||||
|
@ -99,7 +99,7 @@ class ModulePassForward : public Module
|
||||
if (!nickrequired.empty())
|
||||
{
|
||||
/* Check if nick exists and its server is ulined */
|
||||
User* u = ServerInstance->FindNick(nickrequired);
|
||||
User* u = ServerInstance->Users.Find(nickrequired);
|
||||
if (!u || !u->server->IsULine())
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class RemoveBase : public Command
|
||||
if (IS_LOCAL(user))
|
||||
target = ServerInstance->FindNickOnly(username);
|
||||
else
|
||||
target = ServerInstance->FindNick(username);
|
||||
target = ServerInstance->Users.Find(username);
|
||||
|
||||
/* And the channel we're meant to be removing them from */
|
||||
channel = ServerInstance->FindChan(channame);
|
||||
|
@ -49,7 +49,7 @@ class CommandSajoin : public Command
|
||||
const std::string& channel = parameters[channelindex];
|
||||
const std::string& nickname = parameters.size() > 1 ? parameters[0] : user->nick;
|
||||
|
||||
User* dest = ServerInstance->FindNick(nickname);
|
||||
User* dest = ServerInstance->Users.Find(nickname);
|
||||
if ((dest) && (dest->registered == REG_ALL))
|
||||
{
|
||||
if (user != dest && !user->HasPrivPermission("users/sajoin-others"))
|
||||
|
@ -37,7 +37,7 @@ class CommandSakick : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[1]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[1]);
|
||||
Channel* channel = ServerInstance->FindChan(parameters[0]);
|
||||
|
||||
if ((dest) && (dest->registered == REG_ALL) && (channel))
|
||||
|
@ -40,7 +40,7 @@ class CommandSanick : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* target = ServerInstance->FindNick(parameters[0]);
|
||||
User* target = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
/* Do local sanity checks and bails */
|
||||
if (IS_LOCAL(user))
|
||||
|
@ -42,7 +42,7 @@ class CommandSapart : public Command
|
||||
if (CommandParser::LoopCall(user, this, parameters, 1))
|
||||
return CMD_FAILURE;
|
||||
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
Channel* channel = ServerInstance->FindChan(parameters[1]);
|
||||
std::string reason;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class CommandSaquit : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
if ((dest) && (dest->registered == REG_ALL))
|
||||
{
|
||||
if (dest->server->IsULine())
|
||||
|
@ -92,7 +92,7 @@ class ModuleServProtectMode : public Module, public Whois::EventListener, public
|
||||
|
||||
/* Check if the parameter is a valid nick/uuid
|
||||
*/
|
||||
User *u = ServerInstance->FindNick(param);
|
||||
User *u = ServerInstance->Users.Find(param);
|
||||
if (u)
|
||||
{
|
||||
Membership* memb = chan->GetUser(u);
|
||||
|
@ -59,11 +59,11 @@ class WhoisNoticeCmd : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
if (!dest)
|
||||
return CMD_FAILURE;
|
||||
|
||||
User* source = ServerInstance->FindNick(parameters[1]);
|
||||
User* source = ServerInstance->Users.Find(parameters[1]);
|
||||
|
||||
if (IS_LOCAL(dest) && source)
|
||||
HandleFast(dest, source);
|
||||
|
@ -74,7 +74,7 @@ class CommandShun : public Command
|
||||
|
||||
std::string target = parameters[0];
|
||||
|
||||
User *find = ServerInstance->FindNick(target);
|
||||
User *find = ServerInstance->Users.Find(target);
|
||||
if ((find) && (find->registered == REG_ALL))
|
||||
target = std::string("*!*@") + find->GetIPString();
|
||||
|
||||
|
@ -116,7 +116,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm
|
||||
else
|
||||
{
|
||||
// user target?
|
||||
User* d = ServerInstance->FindNick(dest);
|
||||
User* d = ServerInstance->Users.Find(dest);
|
||||
if (!d || IS_LOCAL(d))
|
||||
return;
|
||||
TreeServer* tsd = TreeServer::Get(d)->GetRoute();
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
CmdResult CommandSVSNick::Handle(User* user, Params& parameters)
|
||||
{
|
||||
User* u = ServerInstance->FindNick(parameters[0]);
|
||||
User* u = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if (u && IS_LOCAL(u))
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ std::string Translate::ModeChangeListToParams(const Modes::ChangeList::List& mod
|
||||
|
||||
if (mh->IsPrefixMode())
|
||||
{
|
||||
User* target = ServerInstance->FindNick(item.param);
|
||||
User* target = ServerInstance->Users.Find(item.param);
|
||||
if (target)
|
||||
{
|
||||
ret.append(target->uuid);
|
||||
|
@ -99,7 +99,7 @@ TreeServer* SpanningTreeUtilities::FindRouteTarget(const std::string& target)
|
||||
if (server)
|
||||
return server;
|
||||
|
||||
User* const user = ServerInstance->FindNick(target);
|
||||
User* const user = ServerInstance->Users.Find(target);
|
||||
if (user)
|
||||
return TreeServer::Get(user);
|
||||
|
||||
|
@ -110,7 +110,7 @@ class AuthQuery : public SQL::Query
|
||||
|
||||
void OnError(SQL::Error& error) override
|
||||
{
|
||||
User* user = ServerInstance->FindNick(uid);
|
||||
User* user = ServerInstance->Users.Find(uid);
|
||||
if (!user)
|
||||
return;
|
||||
pendingExt.set(user, AUTH_STATE_FAIL);
|
||||
|
@ -128,7 +128,7 @@ class OperQuery : public SQL::Query
|
||||
// Call /oper after placing all blocks from the SQL table into the config->oper_blocks list.
|
||||
void OperExec()
|
||||
{
|
||||
User* user = ServerInstance->FindNick(uid);
|
||||
User* user = ServerInstance->Users.Find(uid);
|
||||
LocalUser* localuser = IS_LOCAL(user);
|
||||
// This should never be true
|
||||
if (!localuser)
|
||||
|
@ -50,7 +50,7 @@ class CommandSwhois : public Command
|
||||
|
||||
CmdResult Handle(User* user, const Params& parameters) override
|
||||
{
|
||||
User* dest = ServerInstance->FindNick(parameters[0]);
|
||||
User* dest = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
if (!dest) // allow setting swhois using SWHOIS before reg
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ class CommandUninvite : public Command
|
||||
if (IS_LOCAL(user))
|
||||
u = ServerInstance->FindNickOnly(parameters[0]);
|
||||
else
|
||||
u = ServerInstance->FindNick(parameters[0]);
|
||||
u = ServerInstance->Users.Find(parameters[0]);
|
||||
|
||||
Channel* c = ServerInstance->FindChan(parameters[1]);
|
||||
|
||||
|
@ -435,6 +435,17 @@ already_sent_t UserManager::NextAlreadySentId()
|
||||
return already_sent_id;
|
||||
}
|
||||
|
||||
User* UserManager::Find(const std::string& nickuuid)
|
||||
{
|
||||
if (nickuuid.empty())
|
||||
return nullptr;
|
||||
|
||||
if (isdigit(nickuuid[0]))
|
||||
return FindUUID(nickuuid);
|
||||
|
||||
return FindNick(nickuuid);
|
||||
}
|
||||
|
||||
User* UserManager::FindUUID(const std::string& uuid)
|
||||
{
|
||||
if (uuid.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user