From 8a8cee40613c7a39d537c7b624285d914e209f7d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Sun, 2 Nov 2025 17:23:57 +0000 Subject: [PATCH] Add a method for consistently updating the NickAlias seen data. --- include/account.h | 5 +++++ modules/nickserv/ns_group.cpp | 2 +- modules/nickserv/ns_register.cpp | 2 +- src/nickalias.cpp | 7 +++++++ src/users.cpp | 11 ++--------- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/account.h b/include/account.h index 570338366..c3ca8ee1f 100644 --- a/include/account.h +++ b/include/account.h @@ -107,6 +107,11 @@ public: */ time_t GetVHostCreated() const; + /** Update the last seen time for the nickname. + * @param u The user who is using the nickname. + */ + void UpdateSeen(User *u); + /** Finds a registered nick * @param nick The nick to lookup * @return the nick, if found diff --git a/modules/nickserv/ns_group.cpp b/modules/nickserv/ns_group.cpp index 5ee9a1581..37b486f06 100644 --- a/modules/nickserv/ns_group.cpp +++ b/modules/nickserv/ns_group.cpp @@ -55,7 +55,7 @@ public: if (u != NULL) { - na->last_userhost = u->GetIdent() + "@" + u->GetDisplayedHost(); + na->UpdateSeen(u); IRCD->SendLogin(u, na); // protocol modules prevent this on unconfirmed accounts u->Login(target->nc); diff --git a/modules/nickserv/ns_register.cpp b/modules/nickserv/ns_register.cpp index 0e55e211f..deaed62ed 100644 --- a/modules/nickserv/ns_register.cpp +++ b/modules/nickserv/ns_register.cpp @@ -140,7 +140,7 @@ public: nc->pass = encpass; if (u) - na->last_userhost = u->GetIdent() + "@" + u->GetDisplayedHost(); + na->UpdateSeen(u); Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; diff --git a/src/nickalias.cpp b/src/nickalias.cpp index e086c535f..db0529a20 100644 --- a/src/nickalias.cpp +++ b/src/nickalias.cpp @@ -127,6 +127,13 @@ time_t NickAlias::GetVHostCreated() const return this->vhost_created; } +void NickAlias::UpdateSeen(User *u) +{ + this->last_seen = Anope::CurTime; + this->last_userhost = u->GetIdent() + "@" + u->GetDisplayedHost(); + this->last_userhost_real = u->GetIdent() + "@" + u->host; +} + NickAlias *NickAlias::Find(const Anope::string &nick) { nickalias_map::const_iterator it = NickAliasList->find(nick); diff --git a/src/users.cpp b/src/users.cpp index f0039c19b..ec8d9be85 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -358,11 +358,7 @@ void User::SendMessage(CommandSource &source, const Anope::string &msg) void User::Identify(NickAlias *na) { if (this->nick.equals_ci(na->nick)) - { - na->last_userhost = this->GetIdent() + "@" + this->GetDisplayedHost(); - na->last_userhost_real = this->GetIdent() + "@" + this->host; - na->last_seen = Anope::CurTime; - } + na->UpdateSeen(this); IRCD->SendLogin(this, na); @@ -515,10 +511,7 @@ void User::UpdateHost() NickAlias *na = NickAlias::Find(this->nick); if (na && this->IsIdentified(true)) - { - na->last_userhost = this->GetIdent() + "@" + this->GetDisplayedHost(); - na->last_userhost_real = this->GetIdent() + "@" + this->host; - } + na->UpdateSeen(this); } void User::SetAway(const Anope::string &msg, time_t ts)