mirror of
https://github.com/anope/anope.git
synced 2026-07-09 13:43:14 +02:00
Fix using User::Account where User::IsIdentified should be used.
The former causes a dereference which cause a database update. This is not good for performance with db_sql_live on bigger networks.
This commit is contained in:
@@ -188,7 +188,7 @@ class Greet : public Module
|
||||
* to has synced, or we'll get greet-floods when the net
|
||||
* recovers from a netsplit. -GD
|
||||
*/
|
||||
if (!c->ci || !c->ci->bi || !user->server->IsSynced() || !user->Account())
|
||||
if (!c->ci || !c->ci->bi || !user->server->IsSynced() || !user->IsIdentified())
|
||||
return;
|
||||
|
||||
Anope::string *greet = ns_greet.Get(user->Account());
|
||||
|
||||
@@ -82,7 +82,7 @@ class CommandNSIdentify : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (u->Account() && na && u->Account() == na->nc)
|
||||
if (u->IsIdentified() && na && u->Account() == na->nc)
|
||||
{
|
||||
source.Reply(_("You are already identified."));
|
||||
return;
|
||||
|
||||
@@ -1286,7 +1286,7 @@ class NSSet : public Module
|
||||
if (chan->ci)
|
||||
{
|
||||
/* Only give modes if autoop is set */
|
||||
give_modes &= !user->Account() || autoop.HasExt(user->Account());
|
||||
give_modes &= !user->IsIdentified() || autoop.HasExt(user->Account());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1321,13 +1321,13 @@ class NSSet : public Module
|
||||
|
||||
void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
|
||||
{
|
||||
if (u->Account() && setter.GetUser() == u)
|
||||
if (u->IsIdentified() && setter.GetUser() == u)
|
||||
u->Account()->last_modes = u->GetModeList();
|
||||
}
|
||||
|
||||
void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) anope_override
|
||||
{
|
||||
if (u->Account() && setter.GetUser() == u)
|
||||
if (u->IsIdentified() && setter.GetUser() == u)
|
||||
u->Account()->last_modes = u->GetModeList();
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class CommandNSStatus : public Command
|
||||
else if (u2->IsIdentified() && na && na->nc == u2->Account()) /* Nick is identified */
|
||||
source.Reply("STATUS %s %d %s", nickbuf.c_str(), 3, u2->Account()->display.c_str());
|
||||
else if (u2->IsRecognized()) /* Nick is recognised, but NOT identified */
|
||||
source.Reply("STATUS %s %d %s", nickbuf.c_str(), 2, u2->Account() ? u2->Account()->display.c_str() : "");
|
||||
source.Reply("STATUS %s %d %s", nickbuf.c_str(), 2, u2->IsIdentified() ? u2->Account()->display.c_str() : "");
|
||||
else if (!na) /* Nick is online, but NOT a registered */
|
||||
source.Reply("STATUS %s %d %s", nickbuf.c_str(), 0, "");
|
||||
else
|
||||
|
||||
@@ -143,7 +143,7 @@ class OnIdentifyInterface : public LDAPInterface
|
||||
{
|
||||
User *u = User::Find(uid);
|
||||
|
||||
if (!u || !u->Account() || r.empty())
|
||||
if (!u || !u->IsIdentified() || r.empty())
|
||||
return;
|
||||
|
||||
try
|
||||
|
||||
@@ -23,7 +23,7 @@ class IdentifyInterface : public LDAPInterface
|
||||
|
||||
void OnResult(const LDAPResult &r) anope_override
|
||||
{
|
||||
if (!u || !u->Account())
|
||||
if (!u || !u->IsIdentified())
|
||||
return;
|
||||
|
||||
NickCore *nc = u->Account();
|
||||
|
||||
@@ -46,7 +46,7 @@ class SQLOperResult : public SQL::Interface
|
||||
{
|
||||
SQLOperResultDeleter d(this);
|
||||
|
||||
if (!user || !user->Account())
|
||||
if (!user || !user->IsIdentified())
|
||||
return;
|
||||
|
||||
if (r.Rows() == 0)
|
||||
|
||||
@@ -108,7 +108,7 @@ void IRC2SQL::OnUserConnect(User *u, bool &exempt)
|
||||
query.SetValue("ident", u->GetIdent());
|
||||
query.SetValue("vident", u->GetVIdent());
|
||||
query.SetValue("secure", u->HasMode("SSL") || u->HasExt("ssl") ? "Y" : "N");
|
||||
query.SetValue("account", u->Account() ? u->Account()->display : "");
|
||||
query.SetValue("account", u->IsIdentified() ? u->Account()->display : "");
|
||||
query.SetValue("fingerprint", u->fingerprint);
|
||||
query.SetValue("signon", u->signon);
|
||||
query.SetValue("server", u->server->GetName());
|
||||
@@ -176,7 +176,7 @@ void IRC2SQL::OnUserLogin(User *u)
|
||||
{
|
||||
query = "UPDATE `" + prefix + "user` SET account=@account@ WHERE nick=@nick@";
|
||||
query.SetValue("nick", u->nick);
|
||||
query.SetValue("account", u->Account() ? u->Account()->display : "");
|
||||
query.SetValue("account", u->IsIdentified() ? u->Account()->display : "");
|
||||
this->RunQuery(query);
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class MChanstats : public Module
|
||||
|
||||
const Anope::string GetDisplay(User *u)
|
||||
{
|
||||
if (u && u->Account() && ns_stats.HasExt(u->Account()))
|
||||
if (u && u->IsIdentified() && ns_stats.HasExt(u->Account()))
|
||||
return u->Account()->display;
|
||||
else
|
||||
return "";
|
||||
@@ -527,7 +527,7 @@ class MChanstats : public Module
|
||||
|
||||
void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) anope_override
|
||||
{
|
||||
if (!source || !source->Account() || !c->ci || !cs_stats.HasExt(c->ci))
|
||||
if (!source || !source->IsIdentified() || !c->ci || !cs_stats.HasExt(c->ci))
|
||||
return;
|
||||
query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);";
|
||||
query.SetValue("channel", c->name);
|
||||
@@ -550,7 +550,7 @@ class MChanstats : public Module
|
||||
private:
|
||||
void OnModeChange(Channel *c, User *u)
|
||||
{
|
||||
if (!u || !u->Account() || !c->ci || !cs_stats.HasExt(c->ci))
|
||||
if (!u || !u->IsIdentified() || !c->ci || !cs_stats.HasExt(c->ci))
|
||||
return;
|
||||
|
||||
query = "CALL " + prefix + "chanstats_proc_update(@channel@, @nick@, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0);";
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ class Fantasy : public Module
|
||||
}
|
||||
|
||||
// Command requires registered users only
|
||||
if (!cmd->AllowUnregistered() && !u->Account())
|
||||
if (!cmd->AllowUnregistered() && !u->IsIdentified())
|
||||
return;
|
||||
|
||||
if (params.size() < cmd->min_params)
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class DNSBLResolver : public Request
|
||||
if (!blacklist.replies.empty() && !reply)
|
||||
return;
|
||||
|
||||
if (reply && reply->allow_account && user->Account())
|
||||
if (reply && reply->allow_account && user->IsIdentified())
|
||||
return;
|
||||
|
||||
Anope::string reason = this->blacklist.reason, addr = user->ip.addr();
|
||||
|
||||
@@ -226,7 +226,7 @@ class MyXMLRPCEvent : public XMLRPCEvent
|
||||
request.reply("ip", u->ip.addr());
|
||||
request.reply("timestamp", stringify(u->timestamp));
|
||||
request.reply("signon", stringify(u->signon));
|
||||
if (u->Account())
|
||||
if (u->IsIdentified())
|
||||
{
|
||||
request.reply("account", iface->Sanitize(u->Account()->display));
|
||||
if (u->Account()->o)
|
||||
|
||||
@@ -253,7 +253,7 @@ namespace InspIRCdExtban
|
||||
{
|
||||
const Anope::string &mask = e->GetMask();
|
||||
Anope::string real_mask = mask.substr(2);
|
||||
return !u->Account() && Entry("BAN", real_mask).Matches(u);
|
||||
return !u->IsIdentified() && Entry("BAN", real_mask).Matches(u);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ namespace InspIRCdExtban
|
||||
{
|
||||
const Anope::string &mask = e->GetMask();
|
||||
Anope::string real_mask = mask.substr(2);
|
||||
return !u->Account() && Entry("BAN", real_mask).Matches(u);
|
||||
return !u->IsIdentified() && Entry("BAN", real_mask).Matches(u);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ namespace UnrealExtban
|
||||
const Anope::string &mask = e->GetMask();
|
||||
Anope::string real_mask = mask.substr(3);
|
||||
|
||||
return u->Account() && Anope::Match(u->Account()->display, real_mask);
|
||||
return u->IsIdentified() && Anope::Match(u->Account()->display, real_mask);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -559,10 +559,10 @@ namespace UnrealExtban
|
||||
const Anope::string &mask = e->GetMask();
|
||||
Anope::string real_mask = mask.substr(3);
|
||||
|
||||
if (real_mask == "0" && !u->Account()) /* ~a:0 is special and matches all unauthenticated users */
|
||||
if (real_mask == "0" && !u->IsIdentified()) /* ~a:0 is special and matches all unauthenticated users */
|
||||
return true;
|
||||
|
||||
return u->Account() && Anope::Match(u->Account()->display, real_mask);
|
||||
return u->IsIdentified() && Anope::Match(u->Account()->display, real_mask);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ class MemoServCore : public Module, public MemoServService
|
||||
|
||||
if (ci->AccessFor(cu->user).HasPriv("MEMO"))
|
||||
{
|
||||
if (cu->user->Account() && cu->user->Account()->HasExt("MEMO_RECEIVE"))
|
||||
if (cu->user->IsIdentified() && cu->user->Account()->HasExt("MEMO_RECEIVE"))
|
||||
cu->user->SendMessage(MemoServ, MEMO_NEW_X_MEMO_ARRIVED, ci->name.c_str(), Config->StrictPrivmsg.c_str(), MemoServ->nick.c_str(), ci->name.c_str(), mi->memos->size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ class NickServCore : public Module, public NickServService
|
||||
const NickAlias *na = NickAlias::Find(u->nick);
|
||||
|
||||
const Anope::string &unregistered_notice = Config->GetModule(this)->Get<const Anope::string>("unregistered_notice");
|
||||
if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na && !u->Account())
|
||||
if (!Config->GetModule("nickserv")->Get<bool>("nonicknameownership") && !unregistered_notice.empty() && !na && !u->IsIdentified())
|
||||
u->SendMessage(NickServ, unregistered_notice.replace_all_cs("%n", u->nick));
|
||||
else if (na && !u->IsIdentified(true))
|
||||
this->Validate(u);
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ const char *Language::Translate(const char *string)
|
||||
|
||||
const char *Language::Translate(User *u, const char *string)
|
||||
{
|
||||
if (u && u->Account())
|
||||
if (u && u->IsIdentified())
|
||||
return Translate(u->Account(), string);
|
||||
else
|
||||
return Translate("", string);
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ void MemoInfo::Del(unsigned index)
|
||||
bool MemoInfo::HasIgnore(User *u)
|
||||
{
|
||||
for (unsigned i = 0; i < this->ignores.size(); ++i)
|
||||
if (u->nick.equals_ci(this->ignores[i]) || (u->Account() && u->Account()->display.equals_ci(this->ignores[i])) || Anope::Match(u->GetMask(), Anope::string(this->ignores[i])))
|
||||
if (u->nick.equals_ci(this->ignores[i]) || (u->IsIdentified() && u->Account()->display.equals_ci(this->ignores[i])) || Anope::Match(u->GetMask(), Anope::string(this->ignores[i])))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user