summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-04-12 16:00:17 +0200
committerattilamolnar <attilamolnar@hush.com>2013-04-13 16:05:54 +0200
commitb98acac5c91ecb08da28d70185818a19991eb1db (patch)
treea72446ebf241ced2b21939eb8adb7a0045274dfe /src/modules
parent988d8218071b504521bd1da6c2275db877d857b9 (diff)
Channel::JoinUser() and Channel::ForceChan() changes
Convert static Channel::ForceChan() to non-static Channel::ForceJoin() that joins a user to a channel, no permission checks The (static) Channel::JoinUser() now has a LocalUser parameter, and no longer have TS and bursting parameters. If the channel doesn't exist, it is created using current time as TS
Diffstat (limited to 'src/modules')
-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
10 files changed, 40 insertions, 37 deletions
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;
}