class CommandIJoin : public UserOnlyServerCommand<CommandIJoin>
{
public:
- CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 1) { }
+ CommandIJoin(Module* Creator) : UserOnlyServerCommand<CommandIJoin>(Creator, "IJOIN", 2) { }
CmdResult HandleRemote(RemoteUser* user, std::vector<std::string>& params);
};
if (command == "IJOIN")
{
// Convert
- // :<uid> IJOIN <chan> [<ts> [<flags>]]
+ // :<uid> IJOIN <chan> <membid> [<ts> [<flags>]]
// to
// :<sid> FJOIN <chan> <ts> + [<flags>],<uuid>
std::string::size_type c = line.find(' ', b + 1);
if (c == std::string::npos)
+ return;
+
+ std::string::size_type d = line.find(' ', c + 1);
+ // Erase membership id first
+ line.erase(c, d-c);
+ if (d == std::string::npos)
{
// No TS or modes in the command
// :22DAAAAAB IJOIN #chan
}
else
{
- std::string::size_type d = line.find(' ', c + 1);
+ d = line.find(' ', c + 1);
if (d == std::string::npos)
{
// TS present, no modes
}
bool apply_modes;
- if (params.size() > 1)
+ if (params.size() > 2)
{
- time_t RemoteTS = ServerCommand::ExtractTS(params[1]);
+ time_t RemoteTS = ServerCommand::ExtractTS(params[2]);
if (RemoteTS < chan->age)
throw ProtocolException("Attempted to lower TS via IJOIN. LocalTS=" + ConvToStr(chan->age));
- apply_modes = ((params.size() > 2) && (RemoteTS == chan->age));
+ apply_modes = ((params.size() > 3) && (RemoteTS == chan->age));
}
else
apply_modes = false;
- chan->ForceJoin(user, apply_modes ? ¶ms[2] : NULL);
+ // Join the user and set the membership id to what they sent
+ Membership* memb = chan->ForceJoin(user, apply_modes ? ¶ms[3] : NULL);
+ if (!memb)
+ return CMD_FAILURE;
+
+ memb->id = Membership::IdFromString(params[1]);
return CMD_SUCCESS;
}
{
CmdBuilder params(memb->user, "IJOIN");
params.push_back(memb->chan->name);
+ params.push_int(memb->id);
if (!memb->modes.empty())
{
params.push_back(ConvToStr(memb->chan->age));