]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/ijoin.cpp
m_operjoin Remove duplicated code
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ijoin.cpp
index 8185216d37915f1fe19b0d437bba4c90246f0242..a579848c8321061add6f900862e7eed061ea5e82 100644 (file)
@@ -23,7 +23,7 @@
 #include "treeserver.h"
 #include "treesocket.h"
 
-CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, RemoteUser* user)
+CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
 {
        Channel* chan = ServerInstance->FindChan(params[0]);
        if (!chan)
@@ -32,9 +32,7 @@ CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, Rem
                // Ignore the join and send RESYNC, this will result in the remote server sending all channel data to us
                ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for non-existant channel: " + params[0]);
 
-               parameterlist p;
-               p.push_back(params[0]);
-               Utils->DoOneToOne(ServerInstance->Config->GetSID(), "RESYNC", p, user->server);
+               CmdBuilder("RESYNC").push(params[0]).Unicast(user);
 
                return CMD_FAILURE;
        }
@@ -63,7 +61,7 @@ CmdResult CommandIJoin::HandleRemote(const std::vector<std::string>& params, Rem
        return CMD_SUCCESS;
 }
 
-CmdResult CommandResync::HandleServer(const std::vector<std::string>& params, FakeUser* user)
+CmdResult CommandResync::HandleServer(TreeServer* server, std::vector<std::string>& params)
 {
        ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]);
        Channel* chan = ServerInstance->FindChan(params[0]);
@@ -74,18 +72,13 @@ CmdResult CommandResync::HandleServer(const std::vector<std::string>& params, Fa
                return CMD_FAILURE;
        }
 
-       TreeServer* server = Utils->FindServer(user->server);
-       if (!server)
-               return CMD_FAILURE;
-
-       TreeSocket* socket = server->GetSocket();
-       if (!socket)
+       if (!server->IsLocal())
        {
-               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + user->uuid);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Received RESYNC with a source that is not directly connected: " + server->GetID());
                return CMD_INVALID;
        }
 
        // Send all known information about the channel
-       socket->SyncChannel(chan);
+       server->GetSocket()->SyncChannel(chan);
        return CMD_SUCCESS;
 }