aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-10-29 13:01:42 +0100
committerGravatar Sadie Powell2022-10-29 13:01:42 +0100
commita46b8b8edea0caf94350895acd02f0c90a1027de (patch)
tree378d05f11c9c3ea1e814e3b1d88f8a620bea4a9d
parentMore const correctness. (diff)
Allow UserManager::Find{Nick,UUID,} to ignore unregistered users.
-rw-r--r--include/usermanager.h9
-rw-r--r--include/users.h4
-rw-r--r--src/coremods/core_channel/cmd_invite.cpp6
-rw-r--r--src/coremods/core_channel/cmd_kick.cpp6
-rw-r--r--src/coremods/core_message.cpp16
-rw-r--r--src/coremods/core_user/cmd_ison.cpp4
-rw-r--r--src/coremods/core_user/cmd_userhost.cpp5
-rw-r--r--src/coremods/core_whois.cpp4
-rw-r--r--src/coremods/core_xline/cmd_eline.cpp4
-rw-r--r--src/coremods/core_xline/cmd_gline.cpp4
-rw-r--r--src/coremods/core_xline/cmd_kline.cpp4
-rw-r--r--src/coremods/core_xline/cmd_zline.cpp5
-rw-r--r--src/modules/m_callerid.cpp10
-rw-r--r--src/modules/m_chgident.cpp5
-rw-r--r--src/modules/m_chgname.cpp5
-rw-r--r--src/modules/m_dccallow.cpp6
-rw-r--r--src/modules/m_ircv3_ctctags.cpp8
-rw-r--r--src/modules/m_monitor.cpp12
-rw-r--r--src/modules/m_nicklock.cpp5
-rw-r--r--src/modules/m_remove.cpp6
-rw-r--r--src/modules/m_sajoin.cpp4
-rw-r--r--src/modules/m_sakick.cpp5
-rw-r--r--src/modules/m_samode.cpp4
-rw-r--r--src/modules/m_sanick.cpp4
-rw-r--r--src/modules/m_sapart.cpp7
-rw-r--r--src/modules/m_saquit.cpp4
-rw-r--r--src/modules/m_shun.cpp4
-rw-r--r--src/modules/m_spanningtree/idle.cpp4
-rw-r--r--src/modules/m_spanningtree/nick.cpp4
-rw-r--r--src/modules/m_sslinfo.cpp4
-rw-r--r--src/modules/m_uninvite.cpp4
-rw-r--r--src/modules/m_watch.cpp4
-rw-r--r--src/usermanager.cpp22
33 files changed, 100 insertions, 102 deletions
diff --git a/include/usermanager.h b/include/usermanager.h
index 3ace972e8..b2ac738f0 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -195,19 +195,22 @@ public:
/** 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.
+ * @param fullyconnected Whether to only return users who are fully connected to the server.
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
*/
- User* Find(const std::string& nickuuid);
+ User* Find(const std::string& nickuuid, bool fullyconnected = false);
/** Find a user by their nickname.
* @param nick The nickname of the user to find.
+ * @param fullyconnected Whether to only return users who are fully connected to the server.
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
*/
- User* FindNick(const std::string& nick);
+ User* FindNick(const std::string& nick, bool fullyconnected = false);
/** Find a user by their UUID.
* @param uuid The UUID of the user to find.
+ * @param fullyconnected Whether to only return users who are fully connected to the server.
* @return If the user was found then a pointer to a User object; otherwise, nullptr.
*/
- User* FindUUID(const std::string& uuid);
+ User* FindUUID(const std::string& uuid, bool fullyconnected = false);
};
diff --git a/include/users.h b/include/users.h
index 08265f83f..90f96c903 100644
--- a/include/users.h
+++ b/include/users.h
@@ -556,7 +556,11 @@ public:
*/
void PurgeEmptyChannels();
+ /** @copydoc Cullable::Cull */
Cullable::Result Cull() override;
+
+ /** Determines whether this user is fully connected to the server .*/
+ inline bool IsFullyConnected() const { return registered == REG_ALL; }
};
class CoreExport UserIOHandler final
diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp
index ae8b10717..8cef260a8 100644
--- a/src/coremods/core_channel/cmd_invite.cpp
+++ b/src/coremods/core_channel/cmd_invite.cpp
@@ -61,9 +61,9 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters)
{
User* u;
if (IS_LOCAL(user))
- u = ServerInstance->Users.FindNick(parameters[0]);
+ u = ServerInstance->Users.FindNick(parameters[0], true);
else
- u = ServerInstance->Users.Find(parameters[0]);
+ u = ServerInstance->Users.Find(parameters[0], true);
auto c = ServerInstance->Channels.Find(parameters[1]);
time_t timeout = 0;
@@ -88,7 +88,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters)
user->WriteNumeric(Numerics::NoSuchChannel(parameters[1]));
return CmdResult::FAILURE;
}
- if ((!u) || (u->registered != REG_ALL))
+ if (!u)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp
index f679d2f4a..8f55bb9f6 100644
--- a/src/coremods/core_channel/cmd_kick.cpp
+++ b/src/coremods/core_channel/cmd_kick.cpp
@@ -53,16 +53,16 @@ CmdResult CommandKick::Handle(User* user, const Params& parameters)
return CmdResult::SUCCESS;
if (IS_LOCAL(user))
- u = ServerInstance->Users.FindNick(parameters[1]);
+ u = ServerInstance->Users.FindNick(parameters[1], true);
else
- u = ServerInstance->Users.Find(parameters[1]);
+ u = ServerInstance->Users.Find(parameters[1], true);
if (!c)
{
user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
return CmdResult::FAILURE;
}
- if ((!u) || (u->registered != REG_ALL))
+ if (!u)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[1]));
return CmdResult::FAILURE;
diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp
index 684c2c578..4a1efe450 100644
--- a/src/coremods/core_message.cpp
+++ b/src/coremods/core_message.cpp
@@ -220,23 +220,23 @@ private:
if (targetserver)
{
// The target is a user on a specific server (e.g. jto@tolsun.oulu.fi).
- target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()));
+ target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()), true);
if (target && strcasecmp(target->server->GetPublicName().c_str(), targetserver + 1) != 0)
target = nullptr;
}
else
{
// If the source is a local user then we only look up the target by nick.
- target = ServerInstance->Users.FindNick(parameters[0]);
+ target = ServerInstance->Users.FindNick(parameters[0], true);
}
}
else
{
// Remote users can only specify a nick or UUID as the target.
- target = ServerInstance->Users.Find(parameters[0]);
+ target = ServerInstance->Users.Find(parameters[0], true);
}
- if (!target || target->registered != REG_ALL)
+ if (!target)
{
// The target user does not exist or is not fully registered.
source->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
@@ -361,23 +361,23 @@ public:
if (targetserver)
{
// The target is a user on a specific server (e.g. jto@tolsun.oulu.fi).
- target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()));
+ target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()), true);
if (target && strcasecmp(target->server->GetPublicName().c_str(), targetserver + 1) != 0)
target = nullptr;
}
else
{
// If the source is a local user then we only look up the target by nick.
- target = ServerInstance->Users.FindNick(parameters[0]);
+ target = ServerInstance->Users.FindNick(parameters[0], true);
}
}
else
{
// Remote users can only specify a nick or UUID as the target.
- target = ServerInstance->Users.Find(parameters[0]);
+ target = ServerInstance->Users.Find(parameters[0], true);
}
- if (!target || target->registered != REG_ALL || !target->server->IsService())
+ if (!target || !target->server->IsService())
{
// The target user does not exist, is not fully registered, or is not a service.
user->WriteRemoteNumeric(ERR_NOSUCHSERVICE, parameters[0], "No such service");
diff --git a/src/coremods/core_user/cmd_ison.cpp b/src/coremods/core_user/cmd_ison.cpp
index 9b56104b7..fdfbafb02 100644
--- a/src/coremods/core_user/cmd_ison.cpp
+++ b/src/coremods/core_user/cmd_ison.cpp
@@ -44,8 +44,8 @@ public:
void AddNick(const std::string& nickname)
{
- User* const user = ServerInstance->Users.FindNick(nickname);
- if ((user) && (user->registered == REG_ALL))
+ User* const user = ServerInstance->Users.FindNick(nickname, true);
+ if (user)
Add(user->nick);
}
};
diff --git a/src/coremods/core_user/cmd_userhost.cpp b/src/coremods/core_user/cmd_userhost.cpp
index 6a92f74e8..fa90c3560 100644
--- a/src/coremods/core_user/cmd_userhost.cpp
+++ b/src/coremods/core_user/cmd_userhost.cpp
@@ -41,9 +41,8 @@ CmdResult CommandUserhost::Handle(User* user, const Params& parameters)
size_t paramcount = std::min<size_t>(parameters.size(), 5);
for (size_t i = 0; i < paramcount; ++i)
{
- auto u = ServerInstance->Users.FindNick(parameters[i]);
-
- if ((u) && (u->registered == REG_ALL))
+ auto u = ServerInstance->Users.FindNick(parameters[i], true);
+ if (u)
{
retbuf += u->nick;
diff --git a/src/coremods/core_whois.cpp b/src/coremods/core_whois.cpp
index 812fea6da..496eb9a5b 100644
--- a/src/coremods/core_whois.cpp
+++ b/src/coremods/core_whois.cpp
@@ -300,8 +300,8 @@ CmdResult CommandWhois::HandleLocal(LocalUser* user, const Params& parameters)
return CmdResult::FAILURE;
}
- dest = ServerInstance->Users.FindNick(parameters[userindex]);
- if ((dest) && (dest->registered == REG_ALL))
+ dest = ServerInstance->Users.FindNick(parameters[userindex], true);
+ if (dest)
{
/*
* Okay. Umpteenth attempt at doing this, so let's re-comment...
diff --git a/src/coremods/core_xline/cmd_eline.cpp b/src/coremods/core_xline/cmd_eline.cpp
index ab96061ce..4570aa334 100644
--- a/src/coremods/core_xline/cmd_eline.cpp
+++ b/src/coremods/core_xline/cmd_eline.cpp
@@ -43,8 +43,8 @@ CmdResult CommandEline::Handle(User* user, const Params& parameters)
if (parameters.size() >= 3)
{
IdentHostPair ih;
- auto find = ServerInstance->Users.Find(target);
- if ((find) && (find->registered == REG_ALL))
+ auto find = ServerInstance->Users.Find(target, true);
+ if (find)
{
ih.first = find->GetBanIdent();
ih.second = find->GetIPString();
diff --git a/src/coremods/core_xline/cmd_gline.cpp b/src/coremods/core_xline/cmd_gline.cpp
index 5730eec7e..b1dabb302 100644
--- a/src/coremods/core_xline/cmd_gline.cpp
+++ b/src/coremods/core_xline/cmd_gline.cpp
@@ -44,8 +44,8 @@ CmdResult CommandGline::Handle(User* user, const Params& parameters)
if (parameters.size() >= 3)
{
IdentHostPair ih;
- auto find = ServerInstance->Users.Find(target);
- if ((find) && (find->registered == REG_ALL))
+ auto find = ServerInstance->Users.Find(target, true);
+ if (find)
{
ih.first = find->GetBanIdent();
ih.second = find->GetIPString();
diff --git a/src/coremods/core_xline/cmd_kline.cpp b/src/coremods/core_xline/cmd_kline.cpp
index 842bb406b..660990f5f 100644
--- a/src/coremods/core_xline/cmd_kline.cpp
+++ b/src/coremods/core_xline/cmd_kline.cpp
@@ -44,8 +44,8 @@ CmdResult CommandKline::Handle(User* user, const Params& parameters)
if (parameters.size() >= 3)
{
IdentHostPair ih;
- auto find = ServerInstance->Users.Find(target);
- if ((find) && (find->registered == REG_ALL))
+ auto find = ServerInstance->Users.Find(target, true);
+ if (find)
{
ih.first = find->GetBanIdent();
ih.second = find->GetIPString();
diff --git a/src/coremods/core_xline/cmd_zline.cpp b/src/coremods/core_xline/cmd_zline.cpp
index b4c804263..ff5dd6c12 100644
--- a/src/coremods/core_xline/cmd_zline.cpp
+++ b/src/coremods/core_xline/cmd_zline.cpp
@@ -50,9 +50,8 @@ CmdResult CommandZline::Handle(User* user, const Params& parameters)
return CmdResult::FAILURE;
}
- auto u = ServerInstance->Users.Find(target);
-
- if ((u) && (u->registered == REG_ALL))
+ auto u = ServerInstance->Users.Find(target, true);
+ if (u)
{
target = u->GetIPString();
}
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index 215b2648d..51dcc87cc 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -113,8 +113,8 @@ struct CallerIDExtInfo final
while (s.GetToken(tok))
{
- auto u = ServerInstance->Users.Find(tok);
- if ((u) && (u->registered == REG_ALL) && (!u->quitting))
+ auto u = ServerInstance->Users.Find(tok, true);
+ if (u && !u->quitting)
{
if (dat->accepting.insert(u).second)
{
@@ -172,11 +172,11 @@ class CommandAccept final
User* target;
if (!cmdfrom || !IS_LOCAL(cmdfrom))
- target = ServerInstance->Users.Find(tok);
+ target = ServerInstance->Users.Find(tok, true);
else
- target = ServerInstance->Users.FindNick(tok);
+ target = ServerInstance->Users.FindNick(tok, true);
- if ((!target) || (target->registered != REG_ALL) || (target->quitting))
+ if (target && target->quitting)
target = nullptr;
return std::make_pair(target, !remove);
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index ab6d78b53..0b342dc2b 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -42,9 +42,8 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto dest = ServerInstance->Users.Find(parameters[0]);
-
- if ((!dest) || (dest->registered != REG_ALL))
+ auto dest = ServerInstance->Users.Find(parameters[0], true);
+ if (!dest)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
diff --git a/src/modules/m_chgname.cpp b/src/modules/m_chgname.cpp
index 40761d8d2..d53ed40a3 100644
--- a/src/modules/m_chgname.cpp
+++ b/src/modules/m_chgname.cpp
@@ -40,9 +40,8 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto dest = ServerInstance->Users.Find(parameters[0]);
-
- if ((!dest) || (dest->registered != REG_ALL))
+ auto dest = ServerInstance->Users.Find(parameters[0], true);
+ if (!dest)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp
index 49c81b242..2f4edcad2 100644
--- a/src/modules/m_dccallow.cpp
+++ b/src/modules/m_dccallow.cpp
@@ -234,11 +234,9 @@ public:
}
std::string nick(parameters[0], 1);
- auto target = ServerInstance->Users.FindNick(nick);
-
- if ((target) && (!target->quitting) && (target->registered == REG_ALL))
+ auto target = ServerInstance->Users.FindNick(nick, true);
+ if (target && !target->quitting)
{
-
if (action == '-')
{
// check if it contains any entries
diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp
index eceefeb12..c21b9e762 100644
--- a/src/modules/m_ircv3_ctctags.cpp
+++ b/src/modules/m_ircv3_ctctags.cpp
@@ -161,14 +161,14 @@ private:
if (targetserver)
{
// The target is a user on a specific server (e.g. jto@tolsun.oulu.fi).
- target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()));
+ target = ServerInstance->Users.FindNick(parameters[0].substr(0, targetserver - parameters[0].c_str()), true);
if (target && strcasecmp(target->server->GetPublicName().c_str(), targetserver + 1) != 0)
target = nullptr;
}
else
{
// If the source is a local user then we only look up the target by nick.
- target = ServerInstance->Users.FindNick(parameters[0]);
+ target = ServerInstance->Users.FindNick(parameters[0], true);
// Drop attempts to send a tag message to a server. This usually happens when the
// server is started in debug mode and a client tries to send a typing notification
@@ -180,10 +180,10 @@ private:
else
{
// Remote users can only specify a nick or UUID as the target.
- target = ServerInstance->Users.Find(parameters[0]);
+ target = ServerInstance->Users.Find(parameters[0], true);
}
- if (!target || target->registered != REG_ALL)
+ if (!target)
{
// The target user does not exist or is not fully registered.
source->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp
index 4b1f051bb..abc546ba4 100644
--- a/src/modules/m_monitor.cpp
+++ b/src/modules/m_monitor.cpp
@@ -178,14 +178,6 @@ public:
return nullptr;
}
- static User* FindNick(const std::string& nick)
- {
- auto user = ServerInstance->Users.FindNick(nick);
- if ((user) && (user->registered == REG_ALL))
- return user;
- return nullptr;
- }
-
private:
typedef std::unordered_map<std::string, Entry, irc::insensitive, irc::StrHashComp> NickHash;
@@ -288,7 +280,7 @@ class CommandMonitor final
else if (result != IRCv3::Monitor::Manager::WR_OK)
continue; // Already added or invalid nick
- ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(nick) ? online : offline);
+ ReplyBuilder& out = (ServerInstance->Users.FindNick(nick, true) ? online : offline);
out.Add(nick);
}
@@ -350,7 +342,7 @@ public:
for (const auto& entry : manager.GetWatched(user))
{
- ReplyBuilder& out = (IRCv3::Monitor::Manager::FindNick(entry->GetNick()) ? online : offline);
+ ReplyBuilder& out = (ServerInstance->Users.FindNick(entry->GetNick(), true) ? online : offline);
out.Add(entry->GetNick());
}
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index b173a882c..cd73f468d 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -49,9 +49,8 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto target = ServerInstance->Users.Find(parameters[0]);
-
- if ((!target) || (target->registered != REG_ALL))
+ auto target = ServerInstance->Users.Find(parameters[0], true);
+ if (!target)
{
user->WriteNotice("*** No such nickname: '" + parameters[0] + "'");
return CmdResult::FAILURE;
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index 2b9aaa597..677d5d47e 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -62,9 +62,9 @@ public:
/* Look up the user we're meant to be removing from the channel */
User* target;
if (IS_LOCAL(user))
- target = ServerInstance->Users.FindNick(username);
+ target = ServerInstance->Users.FindNick(username, true);
else
- target = ServerInstance->Users.Find(username);
+ target = ServerInstance->Users.Find(username, true);
/* And the channel we're meant to be removing them from */
auto channel = ServerInstance->Channels.Find(channame);
@@ -75,7 +75,7 @@ public:
user->WriteNumeric(Numerics::NoSuchChannel(channame));
return CmdResult::FAILURE;
}
- if ((!target) || (target->registered != REG_ALL))
+ if (!target)
{
user->WriteNumeric(Numerics::NoSuchNick(username));
return CmdResult::FAILURE;
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index 0b859887d..33c043b04 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -52,8 +52,8 @@ public:
const std::string& channel = parameters[channelindex];
const std::string& nickname = parameters.size() > 1 ? parameters[0] : user->nick;
- auto dest = ServerInstance->Users.Find(nickname);
- if ((dest) && (dest->registered == REG_ALL))
+ auto dest = ServerInstance->Users.Find(nickname, true);
+ if (dest)
{
if (user != dest && !user->HasPrivPermission("users/sajoin-others"))
{
diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp
index b27636669..017074476 100644
--- a/src/modules/m_sakick.cpp
+++ b/src/modules/m_sakick.cpp
@@ -43,10 +43,9 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto dest = ServerInstance->Users.Find(parameters[1]);
auto channel = ServerInstance->Channels.Find(parameters[0]);
-
- if ((dest) && (dest->registered == REG_ALL) && (channel))
+ auto dest = ServerInstance->Users.Find(parameters[1], true);
+ if (channel && dest)
{
const std::string& reason = (parameters.size() > 2) ? parameters[2] : dest->nick;
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index 578c252bc..c95e5f010 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -46,8 +46,8 @@ public:
{
if (!ServerInstance->Channels.IsPrefix(parameters[0][0]))
{
- auto target = ServerInstance->Users.FindNick(parameters[0]);
- if ((!target) || (target->registered != REG_ALL))
+ auto target = ServerInstance->Users.FindNick(parameters[0], true);
+ if (!target)
{
user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
return CmdResult::FAILURE;
diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp
index 062caf72f..b701bebfc 100644
--- a/src/modules/m_sanick.cpp
+++ b/src/modules/m_sanick.cpp
@@ -43,7 +43,7 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto target = ServerInstance->Users.Find(parameters[0]);
+ auto target = ServerInstance->Users.Find(parameters[0], true);
/* Do local sanity checks and bails */
if (IS_LOCAL(user))
@@ -54,7 +54,7 @@ public:
return CmdResult::FAILURE;
}
- if ((!target) || (target->registered != REG_ALL))
+ if (!target)
{
user->WriteNotice("*** No such nickname: '" + parameters[0] + "'");
return CmdResult::FAILURE;
diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp
index 30134cf00..108bfda14 100644
--- a/src/modules/m_sapart.cpp
+++ b/src/modules/m_sapart.cpp
@@ -47,12 +47,11 @@ public:
if (CommandParser::LoopCall(user, this, parameters, 1))
return CmdResult::FAILURE;
- auto dest = ServerInstance->Users.Find(parameters[0]);
+ auto dest = ServerInstance->Users.Find(parameters[0], true);
auto channel = ServerInstance->Channels.Find(parameters[1]);
- std::string reason;
-
- if ((dest) && (dest->registered == REG_ALL) && (channel))
+ if (dest && channel)
{
+ std::string reason;
if (parameters.size() > 2)
reason = parameters[2];
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index 3229e8e5c..54d81076f 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -45,8 +45,8 @@ public:
CmdResult Handle(User* user, const Params& parameters) override
{
- auto dest = ServerInstance->Users.Find(parameters[0]);
- if ((dest) && (dest->registered == REG_ALL))
+ auto dest = ServerInstance->Users.Find(parameters[0], true);
+ if (dest)
{
if (dest->IsModeSet(servprotectmode))
{
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 96f9260ae..8837eef95 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -71,8 +71,8 @@ public:
std::string target = parameters[0];
- auto find = ServerInstance->Users.Find(target);
- if ((find) && (find->registered == REG_ALL))
+ auto find = ServerInstance->Users.Find(target, true);
+ if (find)
target = "*!" + find->GetBanIdent() + "@" + find->GetIPString();
if (parameters.size() == 1)
diff --git a/src/modules/m_spanningtree/idle.cpp b/src/modules/m_spanningtree/idle.cpp
index c4bc9b191..fa7e87548 100644
--- a/src/modules/m_spanningtree/idle.cpp
+++ b/src/modules/m_spanningtree/idle.cpp
@@ -39,8 +39,8 @@ CmdResult CommandIdle::HandleRemote(RemoteUser* issuer, Params& params)
* the number of seconds 'issuer' has been idle.
*/
- auto target = ServerInstance->Users.FindUUID(params[0]);
- if ((!target) || (target->registered != REG_ALL))
+ auto target = ServerInstance->Users.FindUUID(params[0], true);
+ if (!target)
return CmdResult::FAILURE;
LocalUser* localtarget = IS_LOCAL(target);
diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp
index 734e81251..4663a5df2 100644
--- a/src/modules/m_spanningtree/nick.cpp
+++ b/src/modules/m_spanningtree/nick.cpp
@@ -37,8 +37,8 @@ CmdResult CommandNick::HandleRemote(::RemoteUser* user, Params& params)
* On nick messages, check that the nick doesn't already exist here.
* If it does, perform collision logic.
*/
- auto x = ServerInstance->Users.FindNick(params[0]);
- if ((x) && (x != user) && (x->registered == REG_ALL))
+ auto x = ServerInstance->Users.FindNick(params[0], true);
+ if (x && x != user)
{
// 'x' is the already existing user using the same nick as params[0]
// 'user' is the user trying to change nick to the in use nick
diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp
index 457dc436a..5366f4ddd 100644
--- a/src/modules/m_sslinfo.cpp
+++ b/src/modules/m_sslinfo.cpp
@@ -192,8 +192,8 @@ private:
CmdResult HandleUser(LocalUser* source, const std::string& nick)
{
- auto target = ServerInstance->Users.FindNick(nick);
- if (!target || target->registered != REG_ALL)
+ auto target = ServerInstance->Users.FindNick(nick, true);
+ if (!target)
{
source->WriteNumeric(Numerics::NoSuchNick(nick));
return CmdResult::FAILURE;
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index 2462101bc..d6f4762c8 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -53,13 +53,13 @@ public:
{
User* u;
if (IS_LOCAL(user))
- u = ServerInstance->Users.FindNick(parameters[0]);
+ u = ServerInstance->Users.FindNick(parameters[0], true);
else
u = ServerInstance->Users.Find(parameters[0]);
auto c = ServerInstance->Channels.Find(parameters[1]);
- if ((!c) || (!u) || (u->registered != REG_ALL))
+ if (!c || !u)
{
if (!c)
{
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index 9f3010ad6..2a1f8f2d6 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -54,7 +54,7 @@ class CommandWatch final
static void SendOnlineOffline(LocalUser* user, const std::string& nick, bool show_offline = true)
{
- User* target = IRCv3::Monitor::Manager::FindNick(nick);
+ User* target = ServerInstance->Users.FindNick(nick, true);
if (target)
{
// The away state should only be sent if the client requests away notifications for a nick but 2.0 always sends them so we do that too
@@ -92,7 +92,7 @@ class CommandWatch final
if (!manager.Unwatch(user, nick))
return;
- User* target = IRCv3::Monitor::Manager::FindNick(nick);
+ User* target = ServerInstance->Users.FindNick(nick, true);
if (target)
user->WriteNumeric(RPL_WATCHOFF, target->nick, target->ident, target->GetDisplayedHost(), target->nickchanged, "stopped watching");
else
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index c49c565d6..9755da400 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -400,18 +400,18 @@ uint64_t UserManager::NextAlreadySentId()
return already_sent_id;
}
-User* UserManager::Find(const std::string& nickuuid)
+User* UserManager::Find(const std::string& nickuuid, bool fullyconnected)
{
if (nickuuid.empty())
return nullptr;
if (isdigit(nickuuid[0]))
- return FindUUID(nickuuid);
+ return FindUUID(nickuuid, fullyconnected);
- return FindNick(nickuuid);
+ return FindNick(nickuuid, fullyconnected);
}
-User* UserManager::FindNick(const std::string& nick)
+User* UserManager::FindNick(const std::string& nick, bool fullyconnected)
{
if (nick.empty())
return nullptr;
@@ -420,10 +420,14 @@ User* UserManager::FindNick(const std::string& nick)
if (uiter == this->clientlist.end())
return nullptr;
- return uiter->second;
+ User* user = uiter->second;
+ if (fullyconnected && !user->IsFullyConnected())
+ return nullptr;
+
+ return user;
}
-User* UserManager::FindUUID(const std::string& uuid)
+User* UserManager::FindUUID(const std::string& uuid, bool fullyconnected)
{
if (uuid.empty())
return nullptr;
@@ -432,5 +436,9 @@ User* UserManager::FindUUID(const std::string& uuid)
if (uiter == this->uuidlist.end())
return nullptr;
- return uiter->second;
+ User* user = uiter->second;
+ if (fullyconnected && !user->IsFullyConnected())
+ return nullptr;
+
+ return user;
}