summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/configreader.h9
-rw-r--r--src/configreader.cpp11
-rw-r--r--src/coremods/core_channel/cmd_invite.cpp8
-rw-r--r--src/coremods/core_channel/core_channel.cpp13
-rw-r--r--src/coremods/core_channel/core_channel.h18
5 files changed, 36 insertions, 23 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 5db6cc44b..9349813d6 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -257,10 +257,7 @@ class CoreExport ServerConfig
/** Bind to IPv6 by default */
bool WildcardIPv6;
- /** Used to indicate who we announce invites to on a channel */
- enum InviteAnnounceState { INVITE_ANNOUNCE_NONE, INVITE_ANNOUNCE_ALL, INVITE_ANNOUNCE_OPS, INVITE_ANNOUNCE_DYNAMIC };
-
- /** This holds all the information in the config file,
+ /** This holds all the information in the config file,
* it's indexed by tag name to a vector of key/values.
*/
ConfigDataHash config_data;
@@ -372,10 +369,6 @@ class CoreExport ServerConfig
*/
bool HideBans;
- /** Announce invites to the channel with a server notice
- */
- InviteAnnounceState AnnounceInvites;
-
/** True if raw I/O is being logged */
bool RawLog;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 4643c7613..58a932981 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -492,17 +492,6 @@ void ServerConfig::Fill()
throw CoreException("Invalid chanmode " + std::string(1, *p) + " was found.");
DisabledCModes.set(*p - 'A');
}
-
- std::string v = security->getString("announceinvites");
-
- if (v == "ops")
- AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_OPS;
- else if (v == "all")
- AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_ALL;
- else if (v == "dynamic")
- AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_DYNAMIC;
- else
- AnnounceInvites = ServerConfig::INVITE_ANNOUNCE_NONE;
}
// WARNING: it is not safe to use most of the codebase in this function, as it
diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp
index 88b2cf86c..e9ce03a0c 100644
--- a/src/coremods/core_channel/cmd_invite.cpp
+++ b/src/coremods/core_channel/cmd_invite.cpp
@@ -129,15 +129,15 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
char prefix = 0;
unsigned int minrank = 0;
- switch (ServerInstance->Config->AnnounceInvites)
+ switch (announceinvites)
{
- case ServerConfig::INVITE_ANNOUNCE_OPS:
+ case Invite::ANNOUNCE_OPS:
{
prefix = '@';
minrank = OP_VALUE;
break;
}
- case ServerConfig::INVITE_ANNOUNCE_DYNAMIC:
+ case Invite::ANNOUNCE_DYNAMIC:
{
PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
if ((mh) && (mh->name == "halfop"))
@@ -155,7 +155,7 @@ CmdResult CommandInvite::Handle (const std::vector<std::string>& parameters, Use
CUList excepts;
FOREACH_MOD(OnUserInvite, (user, u, c, timeout, minrank, excepts));
- if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE)
+ if (announceinvites != Invite::ANNOUNCE_NONE)
c->WriteAllExcept(user, true, prefix, excepts, "NOTICE %s :*** %s invited %s into the channel", c->name.c_str(), user->nick.c_str(), u->nick.c_str());
}
else if (IS_LOCAL(user))
diff --git a/src/coremods/core_channel/core_channel.cpp b/src/coremods/core_channel/core_channel.cpp
index a49f8492d..b69483166 100644
--- a/src/coremods/core_channel/core_channel.cpp
+++ b/src/coremods/core_channel/core_channel.cpp
@@ -105,6 +105,19 @@ class CoreModChannel : public Module, public CheckExemption::EventListener
}
exemptions.swap(exempts);
+ ConfigTag* securitytag = ServerInstance->Config->ConfValue("security");
+ const std::string announceinvites = securitytag->getString("announceinvites", "dynamic");
+ if (stdalgo::string::equalsci(announceinvites, "none"))
+ cmdinvite.announceinvites = Invite::ANNOUNCE_NONE;
+ else if (stdalgo::string::equalsci(announceinvites, "all"))
+ cmdinvite.announceinvites = Invite::ANNOUNCE_ALL;
+ else if (stdalgo::string::equalsci(announceinvites, "ops"))
+ cmdinvite.announceinvites = Invite::ANNOUNCE_OPS;
+ else if (stdalgo::string::equalsci(announceinvites, "dynamic"))
+ cmdinvite.announceinvites = Invite::ANNOUNCE_DYNAMIC;
+ else
+ throw ModuleException(announceinvites + " is an invalid <security:announceinvites> value, at " + securitytag->getTagLocation());
+
// In 2.0 we allowed limits of 0 to be set. This is non-standard behaviour
// and will be removed in the next major release.
limitmode.minlimit = optionstag->getBool("allowzerolimit", true) ? 0 : 1;
diff --git a/src/coremods/core_channel/core_channel.h b/src/coremods/core_channel/core_channel.h
index 3a74bc661..e59b2cdbd 100644
--- a/src/coremods/core_channel/core_channel.h
+++ b/src/coremods/core_channel/core_channel.h
@@ -34,6 +34,22 @@ namespace Topic
namespace Invite
{
class APIImpl;
+
+ /** Used to indicate who we announce invites to on a channel. */
+ enum AnnounceState
+ {
+ /** Don't send invite announcements. */
+ ANNOUNCE_NONE,
+
+ /** Send invite announcements to all users. */
+ ANNOUNCE_ALL,
+
+ /** Send invite announcements to channel operators and higher. */
+ ANNOUNCE_OPS,
+
+ /** Send invite announcements to channel half-operators (if available) and higher. */
+ ANNOUNCE_DYNAMIC
+ };
}
/** Handle /INVITE.
@@ -43,6 +59,8 @@ class CommandInvite : public Command
Invite::APIImpl& invapi;
public:
+ Invite::AnnounceState announceinvites;
+
/** Constructor for invite.
*/
CommandInvite(Module* parent, Invite::APIImpl& invapiimpl);