summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-03-03 15:07:17 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-03-03 15:07:17 +0100
commitb1173ca66a3a3dc3d1ae0b3f305e1b37e3d5c982 (patch)
tree66fd0557af47b1e6282f942830766f6a96ec87b6
parenta5ca8b892c384d5926bf03353ef878023f0f573d (diff)
Update nick timestamps in User::ChangeNick(), pass the new TS in a parameter
-rw-r--r--include/users.h4
-rw-r--r--src/modules/m_spanningtree/main.cpp7
-rw-r--r--src/modules/m_spanningtree/nick.cpp6
-rw-r--r--src/modules/m_spanningtree/svsnick.cpp3
-rw-r--r--src/users.cpp5
5 files changed, 11 insertions, 14 deletions
diff --git a/include/users.h b/include/users.h
index 24783b304..5ab791eee 100644
--- a/include/users.h
+++ b/include/users.h
@@ -469,7 +469,7 @@ class CoreExport User : public Extensible
* @param newnick The nickname to change to
* @return True if the nickchange was successful.
*/
- bool ForceNickChange(const std::string& newnick) { return ChangeNick(newnick, true); }
+ bool ForceNickChange(const std::string& newnick, time_t newts = 0) { return ChangeNick(newnick, true, newts); }
/** Oper down.
* This will clear the +o usermode and unset the user's oper type
@@ -620,7 +620,7 @@ class CoreExport User : public Extensible
* @param force True if the change is being forced (should not be blocked by modes like +N)
* @return True if the change succeeded
*/
- bool ChangeNick(const std::string& newnick, bool force = false);
+ bool ChangeNick(const std::string& newnick, bool force = false, time_t newts = 0);
/** Send a command to all local users from this user
* The command given must be able to send text with the
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 1782f7e2a..43a3ec2cc 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -583,14 +583,9 @@ void ModuleSpanningTree::OnUserPostNick(User* user, const std::string &oldnick)
{
if (IS_LOCAL(user))
{
+ // The nick TS is updated by the core, we don't do it
CmdBuilder params(user, "NICK");
params.push_back(user->nick);
-
- /** IMPORTANT: We don't update the TS if the oldnick is just a case change of the newnick!
- */
- if ((irc::string(user->nick.c_str()) != assign(oldnick)) && (!this->KeepNickTS))
- user->age = ServerInstance->Time();
-
params.push_back(ConvToStr(user->age));
params.Broadcast();
this->KeepNickTS = false;
diff --git a/src/modules/m_spanningtree/nick.cpp b/src/modules/m_spanningtree/nick.cpp
index eb6c9396f..49ce9a767 100644
--- a/src/modules/m_spanningtree/nick.cpp
+++ b/src/modules/m_spanningtree/nick.cpp
@@ -36,7 +36,7 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>&
return CMD_INVALID;
/* Update timestamp on user when they change nicks */
- user->age = ConvToInt(params[1]);
+ const time_t newts = ConvToInt(params[1]);
/*
* On nick messages, check that the nick doesn't already exist here.
@@ -46,7 +46,7 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>&
if ((x) && (x != user))
{
/* x is local, who is remote */
- int collideret = Utils->DoCollision(x, TreeServer::Get(user), user->age, user->ident, user->GetIPString(), user->uuid);
+ int collideret = Utils->DoCollision(x, TreeServer::Get(user), newts, user->ident, user->GetIPString(), user->uuid);
if (collideret != 1)
{
/*
@@ -57,6 +57,6 @@ CmdResult CommandNick::HandleRemote(RemoteUser* user, std::vector<std::string>&
return CMD_FAILURE;
}
}
- user->ForceNickChange(params[0]);
+ user->ForceNickChange(params[0], newts);
return CMD_SUCCESS;
}
diff --git a/src/modules/m_spanningtree/svsnick.cpp b/src/modules/m_spanningtree/svsnick.cpp
index b3480eb55..01b83dc2c 100644
--- a/src/modules/m_spanningtree/svsnick.cpp
+++ b/src/modules/m_spanningtree/svsnick.cpp
@@ -43,9 +43,8 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
ModuleSpanningTree* st = (ModuleSpanningTree*)(Module*)creator;
st->KeepNickTS = true;
- u->age = NickTS;
- if (!u->ForceNickChange(nick))
+ if (!u->ForceNickChange(nick, NickTS))
{
/* buh. UID them */
if (!u->ForceNickChange(u->uuid))
diff --git a/src/users.cpp b/src/users.cpp
index a5737c9ce..cf1887ce9 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -613,7 +613,7 @@ void User::InvalidateCache()
cached_fullrealhost.clear();
}
-bool User::ChangeNick(const std::string& newnick, bool force)
+bool User::ChangeNick(const std::string& newnick, bool force, time_t newts)
{
if (quitting)
{
@@ -637,6 +637,7 @@ bool User::ChangeNick(const std::string& newnick, bool force)
{
// case change, don't need to check Q:lines and such
// and, if it's identical including case, we can leave right now
+ // We also don't update the nick TS if it's a case change, either
if (newnick == nick)
return true;
}
@@ -710,6 +711,8 @@ bool User::ChangeNick(const std::string& newnick, bool force)
return false;
}
}
+
+ age = newts ? newts : ServerInstance->Time();
}
if (this->registered == REG_ALL)