]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/ijoin.cpp
Get rid of CommandBuilder::push_back.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / ijoin.cpp
index 637321bcb9f81cfa8af7cab4dcbb2802fe8bd256..85838cc7fad65edf2242569820ea480e7401e79e 100644 (file)
 #include "treeserver.h"
 #include "treesocket.h"
 
-CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>& params)
+CmdResult CommandIJoin::HandleRemote(RemoteUser* user, Params& params)
 {
        Channel* chan = ServerInstance->FindChan(params[0]);
        if (!chan)
        {
                // Desync detected, recover
                // 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]);
+               ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Received IJOIN for nonexistent channel: " + params[0]);
 
                CmdBuilder("RESYNC").push(params[0]).Unicast(user);
 
@@ -38,27 +38,24 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, std::vector<std::string>&
        }
 
        bool apply_modes;
-       if (params.size() > 1)
+       if (params.size() > 3)
        {
-               time_t RemoteTS = ConvToInt(params[1]);
-               if (!RemoteTS)
-               {
-                       ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Invalid TS in IJOIN: " + params[1]);
-                       return CMD_INVALID;
-               }
-
-               if (RemoteTS < chan->age)
-                       throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age));
-               apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
+               time_t RemoteTS = ServerCommand::ExtractTS(params[2]);
+               apply_modes = (RemoteTS <= chan->age);
        }
        else
                apply_modes = false;
 
-       chan->ForceJoin(user, apply_modes ? &params[2] : NULL);
+       // Join the user and set the membership id to what they sent
+       Membership* memb = chan->ForceJoin(user, apply_modes ? &params[3] : NULL);
+       if (!memb)
+               return CMD_FAILURE;
+
+       memb->id = Membership::IdFromString(params[1]);
        return CMD_SUCCESS;
 }
 
-CmdResult CommandResync::HandleServer(TreeServer* server, std::vector<std::string>& params)
+CmdResult CommandResync::HandleServer(TreeServer* server, CommandBase::Params& params)
 {
        ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]);
        Channel* chan = ServerInstance->FindChan(params[0]);