]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/svsnick.cpp
Send RPL_SAVENICK from irc2 when renaming a user to their UUID.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / svsnick.cpp
index b3a612ca350f9b53108ac9c213812ace9070066b..8d1bc80ba20cb2dd4a04c6ba7c0024c20fab4b4d 100644 (file)
@@ -1,7 +1,11 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -23,7 +27,7 @@
 #include "main.h"
 #include "commands.h"
 
-CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameters)
+CmdResult CommandSVSNick::Handle(User* user, Params& parameters)
 {
        User* u = ServerInstance->FindNick(parameters[0]);
 
@@ -41,13 +45,13 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
                // 4. SVSNICK arrives
                // 5. Attila_ gets his nick changed to Guest12345 unnecessarily
                //
-               // In this case when the SVSNICK is processed the target has already changed his nick to something
+               // In this case when the SVSNICK is processed the target has already changed their nick to something
                // which isn't protected, so changing the nick again to a Guest nick is not desired.
                // However, if the expected nick TS parameter is present in the SVSNICK then the nick change in step 5
                // won't happen because the timestamps won't match.
                if (parameters.size() > 3)
                {
-                       time_t ExpectedTS = ConvToInt(parameters[3]);
+                       time_t ExpectedTS = ConvToNum<time_t>(parameters[3]);
                        if (u->age != ExpectedTS)
                                return CMD_FAILURE; // Ignore SVSNICK
                }
@@ -56,13 +60,14 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
                if (isdigit(nick[0]))
                        nick = u->uuid;
 
-               time_t NickTS = ConvToInt(parameters[2]);
+               time_t NickTS = ConvToNum<time_t>(parameters[2]);
                if (NickTS <= 0)
                        return CMD_FAILURE;
 
                if (!u->ChangeNick(nick, NickTS))
                {
                        // Changing to 'nick' failed (it may already be in use), change to the uuid
+                       u->WriteNumeric(RPL_SAVENICK, u->uuid, "Your nickname is in use by an older user on a new server.");
                        u->ChangeNick(u->uuid);
                }
        }
@@ -70,10 +75,7 @@ CmdResult CommandSVSNick::Handle(User* user, std::vector<std::string>& parameter
        return CMD_SUCCESS;
 }
 
-RouteDescriptor CommandSVSNick::GetRouting(User* user, const std::vector<std::string>& parameters)
+RouteDescriptor CommandSVSNick::GetRouting(User* user, const Params& parameters)
 {
-       User* u = ServerInstance->FindNick(parameters[0]);
-       if (u)
-               return ROUTE_OPT_UCAST(u->server);
-       return ROUTE_LOCALONLY;
+       return ROUTE_OPT_UCAST(parameters[0]);
 }