summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/channels.h18
-rw-r--r--src/channels.cpp169
-rw-r--r--src/commands/cmd_join.cpp22
-rw-r--r--src/modules/m_banredirect.cpp2
-rw-r--r--src/modules/m_conn_join.cpp9
-rw-r--r--src/modules/m_cycle.cpp10
-rw-r--r--src/modules/m_denychans.cpp4
-rw-r--r--src/modules/m_ojoin.cpp12
-rw-r--r--src/modules/m_operjoin.cpp15
-rw-r--r--src/modules/m_redirect.cpp7
-rw-r--r--src/modules/m_sajoin.cpp11
-rw-r--r--src/modules/m_spanningtree/fjoin.cpp2
-rw-r--r--src/modules/m_spanningtree/svsjoin.cpp5
13 files changed, 154 insertions, 132 deletions
diff --git a/include/channels.h b/include/channels.h
index 3c60fcd6a..2b2681eac 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -35,10 +35,6 @@
*/
class CoreExport Channel : public Extensible, public InviteBase
{
- /** Connect a Channel to a User
- */
- static Channel* ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created);
-
/** Set default modes for the channel on creation
*/
void SetDefaultModes();
@@ -189,16 +185,24 @@ class CoreExport Channel : public Extensible, public InviteBase
*/
void PartUser(User *user, std::string &reason);
- /* Join a user to a channel. May be a channel that doesnt exist yet.
+ /** Join a local user to a channel, with or without permission checks. May be a channel that doesn't exist yet.
* @param user The user to join to the channel.
* @param channame The channel name to join to. Does not have to exist.
* @param key The key of the channel, if given
* @param override If true, override all join restrictions such as +bkil
* @return A pointer to the Channel the user was joined to. A new Channel may have
* been created if the channel did not exist before the user was joined to it.
- * If the user could not be joined to a channel, the return value may be NULL.
+ * If the user could not be joined to a channel, the return value is NULL.
+ */
+ static Channel* JoinUser(LocalUser* user, std::string channame, bool override = false, const std::string& key = "");
+
+ /** Join a user to an existing channel, without doing any permission checks
+ * @param user The user to join to the channel
+ * @param privs Priviliges (prefix mode letters) to give to this user, may be NULL
+ * @param bursting True if this join is the result of a netburst (passed to modules in the OnUserJoin hook)
+ * @param created True if this channel was just created by a local user (passed to modules in the OnUserJoin hook)
*/
- static Channel* JoinUser(User *user, std::string channame, bool override, const std::string& key, bool bursting, time_t TS = 0);
+ void ForceJoin(User* user, const std::string* privs = NULL, bool bursting = false, bool created_by_local = false);
/** Write to a channel, from a user, using va_args for text
* @param user User whos details to prefix the line with
diff --git a/src/channels.cpp b/src/channels.cpp
index f2b0b457a..edb4d056a 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -146,8 +146,11 @@ long Channel::GetUserCounter()
Membership* Channel::AddUser(User* user)
{
- Membership* memb = new Membership(user, this);
- userlist[user] = memb;
+ Membership*& memb = userlist[user];
+ if (memb)
+ return NULL;
+
+ memb = new Membership(user, this);
return memb;
}
@@ -228,14 +231,13 @@ void Channel::SetDefaultModes()
* add a channel to a user, creating the record for it if needed and linking
* it to the user record
*/
-Channel* Channel::JoinUser(User* user, std::string cname, bool override, const std::string& key, bool bursting, time_t TS)
+Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, const std::string& key)
{
- // Fix: unregistered users could be joined using /SAJOIN
- if (!user || user->registered != REG_ALL)
+ if (user->registered != REG_ALL)
+ {
+ ServerInstance->Logs->Log("CHANNELS", LOG_DEBUG, "Attempted to join unregistered user " + user->uuid + " to channel " + cname);
return NULL;
-
- std::string privs;
- Channel *Ptr;
+ }
/*
* We don't restrict the number of channels that remote users or users that are override-joining may be in.
@@ -243,7 +245,7 @@ Channel* Channel::JoinUser(User* user, std::string cname, bool override, const s
* We restrict local operators to OperMaxChans channels.
* This is a lot more logical than how it was formerly. -- w00t
*/
- if (IS_LOCAL(user) && !override)
+ if (!override)
{
if (user->HasPrivPermission("channels/high-join-limit"))
{
@@ -266,97 +268,93 @@ Channel* Channel::JoinUser(User* user, std::string cname, bool override, const s
}
}
+ // Crop channel name if it's too long
if (cname.length() > ServerInstance->Config->Limits.ChanMax)
cname.resize(ServerInstance->Config->Limits.ChanMax);
- Ptr = ServerInstance->FindChan(cname);
- bool created_by_local = false;
+ Channel* chan = ServerInstance->FindChan(cname);
+ bool created_by_local = (chan == NULL); // Flag that will be passed to modules in the OnUserJoin() hook later
+ std::string privs; // Prefix mode(letter)s to give to the joining user
- if (!Ptr)
+ if (!chan)
{
- /*
- * Fix: desync bug was here, don't set @ on remote users - spanningtree handles their permissions. bug #358. -- w00t
- */
- if (!IS_LOCAL(user))
- {
- if (!TS)
- ServerInstance->Logs->Log("CHANNELS",LOG_DEBUG,"*** BUG *** Channel::JoinUser called for REMOTE user '%s' on channel '%s' but no TS given!", user->nick.c_str(), cname.c_str());
- }
- else
- {
- privs = "o";
- created_by_local = true;
- }
+ privs = "o";
- if (IS_LOCAL(user) && override == false)
+ if (override == false)
{
+ // Ask the modules whether they're ok with the join, pass NULL as Channel* as the channel is yet to be created
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (IS_LOCAL(user), NULL, cname, privs, key));
+ FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, NULL, cname, privs, key));
if (MOD_RESULT == MOD_RES_DENY)
- return NULL;
+ return NULL; // A module wasn't happy with the join, abort
}
- Ptr = new Channel(cname, TS);
+ chan = new Channel(cname, ServerInstance->Time());
+ // Set the default modes on the channel (<options:defaultmodes>)
+ chan->SetDefaultModes();
}
else
{
/* Already on the channel */
- if (Ptr->HasUser(user))
+ if (chan->HasUser(user))
return NULL;
- /*
- * remote users are allowed us to bypass channel modes
- * and bans (used by servers)
- */
- if (IS_LOCAL(user) && override == false)
+ if (override == false)
{
ModResult MOD_RESULT;
- FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (IS_LOCAL(user), Ptr, cname, privs, key));
+ FIRST_MOD_RESULT(OnUserPreJoin, MOD_RESULT, (user, chan, cname, privs, key));
+
+ // A module explicitly denied the join and (hopefully) generated a message
+ // describing the situation, so we may stop here without sending anything
if (MOD_RESULT == MOD_RES_DENY)
- {
return NULL;
- }
- else if (MOD_RESULT == MOD_RES_PASSTHRU)
+
+ // If no module returned MOD_RES_DENY or MOD_RES_ALLOW (which is the case
+ // most of the time) then proceed to check channel modes +k, +i, +l and bans,
+ // in this order.
+ // If a module explicitly allowed the join (by returning MOD_RES_ALLOW),
+ // then this entire section is skipped
+ if (MOD_RESULT == MOD_RES_PASSTHRU)
{
- std::string ckey = Ptr->GetModeParameter('k');
- bool invited = IS_LOCAL(user)->IsInvited(Ptr);
+ std::string ckey = chan->GetModeParameter('k');
+ bool invited = user->IsInvited(chan);
bool can_bypass = ServerInstance->Config->InvBypassModes && invited;
if (!ckey.empty())
{
- FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, Ptr, key));
+ FIRST_MOD_RESULT(OnCheckKey, MOD_RESULT, (user, chan, key));
if (!MOD_RESULT.check((ckey == key) || can_bypass))
{
// If no key provided, or key is not the right one, and can't bypass +k (not invited or option not enabled)
- user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), chan->name.c_str());
return NULL;
}
}
- if (Ptr->IsModeSet('i'))
+ if (chan->IsModeSet('i'))
{
- FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, Ptr));
+ FIRST_MOD_RESULT(OnCheckInvite, MOD_RESULT, (user, chan));
if (!MOD_RESULT.check(invited))
{
- user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), chan->name.c_str());
return NULL;
}
}
- std::string limit = Ptr->GetModeParameter('l');
+ std::string limit = chan->GetModeParameter('l');
if (!limit.empty())
{
- FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, Ptr));
- if (!MOD_RESULT.check((Ptr->GetUserCounter() < atol(limit.c_str()) || can_bypass)))
+ FIRST_MOD_RESULT(OnCheckLimit, MOD_RESULT, (user, chan));
+ if (!MOD_RESULT.check((chan->GetUserCounter() < atol(limit.c_str()) || can_bypass)))
{
- user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), chan->name.c_str());
return NULL;
}
}
- if (Ptr->IsBanned(user) && !can_bypass)
+ if (chan->IsBanned(user) && !can_bypass)
{
- user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str());
+ user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), chan->name.c_str());
return NULL;
}
@@ -366,67 +364,78 @@ Channel* Channel::JoinUser(User* user, std::string cname, bool override, const s
*/
if (invited)
{
- IS_LOCAL(user)->RemoveInvite(Ptr);
+ user->RemoveInvite(chan);
}
}
}
}
- if (created_by_local)
- {
- /* As spotted by jilles, dont bother to set this on remote users */
- Ptr->SetDefaultModes();
- }
-
- return Channel::ForceChan(Ptr, user, privs, bursting, created_by_local);
+ // We figured that this join is allowed and also created the
+ // channel if it didn't exist before, now do the actual join
+ chan->ForceJoin(user, &privs, false, created_by_local);
+ return chan;
}
-Channel* Channel::ForceChan(Channel* Ptr, User* user, const std::string &privs, bool bursting, bool created)
+void Channel::ForceJoin(User* user, const std::string* privs, bool bursting, bool created_by_local)
{
- std::string nick = user->nick;
+ Membership* memb = this->AddUser(user);
+ if (!memb)
+ return; // Already on the channel
- Membership* memb = Ptr->AddUser(user);
- user->chans.insert(Ptr);
+ if (IS_SERVER(user))
+ {
+ ServerInstance->Logs->Log("CHANNELS", LOG_DEBUG, "Attempted to join server user " + user->uuid + " to channel " + this->name);
+ return;
+ }
+
+ user->chans.insert(this);
- for (std::string::const_iterator x = privs.begin(); x != privs.end(); x++)
+ if (privs)
{
- const char status = *x;
- ModeHandler* mh = ServerInstance->Modes->FindMode(status, MODETYPE_CHANNEL);
- if (mh)
+ // If the user was granted prefix modes (in the OnUserPreJoin hook, or he's a
+ // remote user and his own server set the modes), then set them internally now
+ memb->modes = *privs;
+ for (std::string::const_iterator i = privs->begin(); i != privs->end(); ++i)
{
- /* Set, and make sure that the mode handler knows this mode was now set */
- Ptr->SetPrefix(user, mh->GetModeChar(), true);
- mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, Ptr, nick, true);
+ ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL);
+ if (mh)
+ {
+ std::string nick = user->nick;
+ /* Set, and make sure that the mode handler knows this mode was now set */
+ this->SetPrefix(user, mh->GetModeChar(), true);
+ mh->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, this, nick, true);
+ }
}
}
+ // Tell modules about this join, they have the chance now to populate except_list with users we won't send the JOIN (and possibly MODE) to
CUList except_list;
- FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created, except_list));
+ FOREACH_MOD(I_OnUserJoin,OnUserJoin(memb, bursting, created_by_local, except_list));
- Ptr->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", Ptr->name.c_str());
+ this->WriteAllExcept(user, false, 0, except_list, "JOIN :%s", this->name.c_str());
/* Theyre not the first ones in here, make sure everyone else sees the modes we gave the user */
- if ((Ptr->GetUserCounter() > 1) && (!memb->modes.empty()))
+ if ((GetUserCounter() > 1) && (!memb->modes.empty()))
{
std::string ms = memb->modes;
for(unsigned int i=0; i < memb->modes.length(); i++)
ms.append(" ").append(user->nick);
except_list.insert(user);
- Ptr->WriteAllExcept(user, !ServerInstance->Config->CycleHostsFromUser, 0, except_list, "MODE %s +%s", Ptr->name.c_str(), ms.c_str());
+ this->WriteAllExcept(user, !ServerInstance->Config->CycleHostsFromUser, 0, except_list, "MODE %s +%s", this->name.c_str(), ms.c_str());
}
if (IS_LOCAL(user))
{
- if (Ptr->topicset)
+ if (this->topicset)
{
- user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str());
- user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset);
+ user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), this->name.c_str(), this->topic.c_str());
+ user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), this->name.c_str(), this->setby.c_str(), (unsigned long)this->topicset);
}
- Ptr->UserList(user);
+ this->UserList(user);
}
+
FOREACH_MOD(I_OnPostJoin,OnPostJoin(memb));
- return Ptr;
}
bool Channel::IsBanned(User* user)
diff --git a/src/commands/cmd_join.cpp b/src/commands/cmd_join.cpp
index 9babdb685..da2ec1b45 100644
--- a/src/commands/cmd_join.cpp
+++ b/src/commands/cmd_join.cpp
@@ -25,33 +25,39 @@
* the same way, however, they can be fully unloaded, where these
* may not.
*/
-class CommandJoin : public Command
+class CommandJoin : public SplitCommand
{
public:
/** Constructor for join.
*/
- CommandJoin ( Module* parent) : Command(parent,"JOIN", 1, 2) { syntax = "<channel>{,<channel>} {<key>{,<key>}}"; Penalty = 2; }
+ CommandJoin(Module* parent)
+ : SplitCommand(parent, "JOIN", 1, 2)
+ {
+ syntax = "<channel>{,<channel>} {<key>{,<key>}}";
+ Penalty = 2;
+ }
+
/** Handle command.
* @param parameters The parameters to the comamnd
* @param pcnt The number of parameters passed to teh command
* @param user The user issuing the command
* @return A value from CmdResult to indicate command success or failure.
*/
- CmdResult Handle(const std::vector<std::string>& parameters, User *user);
+ CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user);
};
/** Handle /JOIN
*/
-CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User *user)
+CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, LocalUser *user)
{
if (parameters.size() > 1)
{
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0, 1, false))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (ServerInstance->IsChannel(parameters[0], ServerInstance->Config->Limits.ChanMax))
{
- Channel::JoinUser(user, parameters[0], false, parameters[1].c_str(), false);
+ Channel::JoinUser(user, parameters[0], false, parameters[1]);
return CMD_SUCCESS;
}
}
@@ -60,9 +66,9 @@ CmdResult CommandJoin::Handle (const std::vector<std::string>& parameters, User
if (ServerInstance->Parser->LoopCall(user, this, parameters, 0, -1, false))
return CMD_SUCCESS;
- if (ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (ServerInstance->IsChannel(parameters[0], ServerInstance->Config->Limits.ChanMax))
{
- Channel::JoinUser(user, parameters[0], false, "", false);
+ Channel::JoinUser(user, parameters[0]);
return CMD_SUCCESS;
}
}
diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp
index 2bb1357db..95321bc03 100644
--- a/src/modules/m_banredirect.cpp
+++ b/src/modules/m_banredirect.cpp
@@ -327,7 +327,7 @@ class ModuleBanRedirect : public Module
user->WriteNumeric(474, "%s %s :Cannot join channel (You are banned)", user->nick.c_str(), chan->name.c_str());
user->WriteNumeric(470, "%s %s %s :You are banned from this channel, so you are automatically transfered to the redirected channel.", user->nick.c_str(), chan->name.c_str(), redir->targetchan.c_str());
nofollow = true;
- Channel::JoinUser(user, redir->targetchan, false, "", false, ServerInstance->Time());
+ Channel::JoinUser(user, redir->targetchan);
nofollow = false;
return MOD_RES_DENY;
}
diff --git a/src/modules/m_conn_join.cpp b/src/modules/m_conn_join.cpp
index 7ba2b0c7d..113e49dff 100644
--- a/src/modules/m_conn_join.cpp
+++ b/src/modules/m_conn_join.cpp
@@ -45,19 +45,20 @@ class ModuleConnJoin : public Module
void OnPostConnect(User* user)
{
- if (!IS_LOCAL(user))
+ LocalUser* localuser = IS_LOCAL(user);
+ if (!localuser)
return;
std::string chanlist = ServerInstance->Config->ConfValue("autojoin")->getString("channel");
- chanlist = user->GetClass()->config->getString("autojoin", chanlist);
+ chanlist = localuser->GetClass()->config->getString("autojoin", chanlist);
irc::commasepstream chans(chanlist);
std::string chan;
while (chans.GetToken(chan))
{
- if (ServerInstance->IsChannel(chan.c_str(), ServerInstance->Config->Limits.ChanMax))
- Channel::JoinUser(user, chan, false, "", false, ServerInstance->Time());
+ if (ServerInstance->IsChannel(chan, ServerInstance->Config->Limits.ChanMax))
+ Channel::JoinUser(localuser, chan);
}
}
};
diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp
index b23bf5b92..bd09f5ae6 100644
--- a/src/modules/m_cycle.cpp
+++ b/src/modules/m_cycle.cpp
@@ -24,16 +24,17 @@
/** Handle /CYCLE
*/
-class CommandCycle : public Command
+class CommandCycle : public SplitCommand
{
public:
- CommandCycle(Module* Creator) : Command(Creator,"CYCLE", 1)
+ CommandCycle(Module* Creator)
+ : SplitCommand(Creator, "CYCLE", 1)
{
Penalty = 3; syntax = "<channel> :[reason]";
TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
}
- CmdResult Handle (const std::vector<std::string> &parameters, User *user)
+ CmdResult HandleLocal(const std::vector<std::string> &parameters, LocalUser* user)
{
Channel* channel = ServerInstance->FindChan(parameters[0]);
std::string reason = ConvToStr("Cycling");
@@ -65,8 +66,7 @@ class CommandCycle : public Command
}
channel->PartUser(user, reason);
-
- Channel::JoinUser(user, parameters[0], true, "", false, ServerInstance->Time());
+ Channel::JoinUser(user, parameters[0], true);
}
return CMD_SUCCESS;
diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp
index 47db28978..b97c74f9b 100644
--- a/src/modules/m_denychans.cpp
+++ b/src/modules/m_denychans.cpp
@@ -45,7 +45,7 @@ class ModuleDenyChannels : public Module
if (!redirect.empty())
{
- if (!ServerInstance->IsChannel(redirect.c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (!ServerInstance->IsChannel(redirect, ServerInstance->Config->Limits.ChanMax))
{
if (user)
user->WriteServ("NOTICE %s :Invalid badchan redirect '%s'", user->nick.c_str(), redirect.c_str());
@@ -115,7 +115,7 @@ class ModuleDenyChannels : public Module
if ((!newchan) || (!(newchan->IsModeSet('L'))))
{
user->WriteNumeric(926, "%s %s :Channel %s is forbidden, redirecting to %s: %s",user->nick.c_str(),cname.c_str(),cname.c_str(),redirect.c_str(), reason.c_str());
- Channel::JoinUser(user, redirect, false, "", false, ServerInstance->Time());
+ Channel::JoinUser(user, redirect);
return MOD_RES_DENY;
}
}
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index 5ac67a649..3c9e84f3d 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -45,28 +45,30 @@ bool op;
/** Handle /OJOIN
*/
-class CommandOjoin : public Command
+class CommandOjoin : public SplitCommand
{
public:
bool active;
- CommandOjoin(Module* parent) : Command(parent,"OJOIN", 1)
+ CommandOjoin(Module* parent) :
+ SplitCommand(parent, "OJOIN", 1)
{
flags_needed = 'o'; Penalty = 0; syntax = "<channel>";
active = false;
TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
}
- CmdResult Handle (const std::vector<std::string>& parameters, User *user)
+ CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
{
// Make sure the channel name is allowable.
- if (!ServerInstance->IsChannel(parameters[0].c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (!ServerInstance->IsChannel(parameters[0], ServerInstance->Config->Limits.ChanMax))
{
user->WriteServ("NOTICE "+user->nick+" :*** Invalid characters in channel name or name too long");
return CMD_FAILURE;
}
active = true;
- Channel* channel = Channel::JoinUser(user, parameters[0].c_str(), false, "", false);
+ // override is false because we want OnUserPreJoin to run
+ Channel* channel = Channel::JoinUser(user, parameters[0], false);
active = false;
if (channel)
diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp
index 2f5dda0ff..864515e0c 100644
--- a/src/modules/m_operjoin.cpp
+++ b/src/modules/m_operjoin.cpp
@@ -78,23 +78,24 @@ class ModuleOperjoin : public Module
virtual void OnPostOper(User* user, const std::string &opertype, const std::string &opername)
{
- if (!IS_LOCAL(user))
+ LocalUser* localuser = IS_LOCAL(user);
+ if (!localuser)
return;
- for(std::vector<std::string>::iterator it = operChans.begin(); it != operChans.end(); it++)
- if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax))
- Channel::JoinUser(user, it->c_str(), override, "", false, ServerInstance->Time());
+ for (std::vector<std::string>::const_iterator i = operChans.begin(); i != operChans.end(); ++i)
+ if (ServerInstance->IsChannel(*i, ServerInstance->Config->Limits.ChanMax))
+ Channel::JoinUser(localuser, *i, override);
- std::string chanList = user->oper->getConfig("autojoin");
+ std::string chanList = localuser->oper->getConfig("autojoin");
if (!chanList.empty())
{
std::vector<std::string> typechans;
tokenize(chanList, typechans);
for (std::vector<std::string>::const_iterator it = typechans.begin(); it != typechans.end(); ++it)
{
- if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (ServerInstance->IsChannel(*it, ServerInstance->Config->Limits.ChanMax))
{
- Channel::JoinUser(user, it->c_str(), override, "", false, ServerInstance->Time());
+ Channel::JoinUser(localuser, *it, override);
}
}
}
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index 72a3649d0..a045af8f8 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -39,7 +39,7 @@ class Redirect : public ModeHandler
{
if (IS_LOCAL(source))
{
- if (!ServerInstance->IsChannel(parameter.c_str(), ServerInstance->Config->Limits.ChanMax))
+ if (!ServerInstance->IsChannel(parameter, ServerInstance->Config->Limits.ChanMax))
{
source->WriteNumeric(403, "%s %s :Invalid channel name", source->nick.c_str(), parameter.c_str());
parameter.clear();
@@ -142,8 +142,7 @@ class ModuleRedirect : public Module
std::string channel = chan->GetModeParameter('L');
/* sometimes broken ulines can make circular or chained +L, avoid this */
- Channel* destchan = NULL;
- destchan = ServerInstance->FindChan(channel);
+ Channel* destchan = ServerInstance->FindChan(channel);
if (destchan && destchan->IsModeSet('L'))
{
user->WriteNumeric(470, "%s %s * :You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop.", user->nick.c_str(), cname.c_str());
@@ -159,7 +158,7 @@ class ModuleRedirect : public Module
else
{
user->WriteNumeric(470, "%s %s %s :You may not join this channel, so you are automatically being transferred to the redirect channel.", user->nick.c_str(), cname.c_str(), channel.c_str());
- Channel::JoinUser(user, channel, false, "", false, ServerInstance->Time());
+ Channel::JoinUser(user, channel);
return MOD_RES_DENY;
}
}
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp
index 2d6bb0f97..7c3d3512a 100644
--- a/src/modules/m_sajoin.cpp
+++ b/src/modules/m_sajoin.cpp
@@ -52,15 +52,14 @@ class CommandSajoin : public Command
return CMD_FAILURE;
}
- /* For local users, we send the JoinUser which may create a channel and set its TS.
+ /* For local users, we call Channel::JoinUser which may create a channel and set its TS.
* For non-local users, we just return CMD_SUCCESS, knowing this will propagate it where it needs to be
- * and then that server will generate the users JOIN or FJOIN instead.
+ * and then that server will handle the command.
*/
- if (IS_LOCAL(dest))
+ LocalUser* localuser = IS_LOCAL(dest);
+ if (localuser)
{
- Channel::JoinUser(dest, parameters[1], true, "", false, ServerInstance->Time());
- /* Fix for dotslasher and w00t - if the join didnt succeed, return CMD_FAILURE so that it doesnt propagate */
- Channel* n = ServerInstance->FindChan(parameters[1]);
+ Channel* n = Channel::JoinUser(localuser, parameters[1], true);
if (n)
{
if (n->HasUser(dest))
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index be13f5318..5e58a164f 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -192,7 +192,7 @@ bool CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_
}
}
- Channel::JoinUser(who, chan->name, true, "", route_back_again->bursting, chan->age);
+ chan->ForceJoin(who, NULL, route_back_again->bursting);
return true;
}
diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp
index a1796740d..6b1d2835c 100644
--- a/src/modules/m_spanningtree/svsjoin.cpp
+++ b/src/modules/m_spanningtree/svsjoin.cpp
@@ -34,8 +34,9 @@ CmdResult CommandSVSJoin::Handle(const std::vector<std::string>& parameters, Use
return CMD_FAILURE;
/* only join if it's local, otherwise just pass it on! */
- if (IS_LOCAL(u))
- Channel::JoinUser(u, parameters[1], false, "", false, ServerInstance->Time());
+ LocalUser* localuser = IS_LOCAL(u);
+ if (localuser)
+ Channel::JoinUser(localuser, parameters[1]);
return CMD_SUCCESS;
}