summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-03-31 13:02:57 +0100
committerPeter Powell <petpow@saberuk.com>2018-03-31 13:16:27 +0100
commit802eed1734cf20e9a2549a5fe343d04c34e83a10 (patch)
tree4a9f2a64bd7913934ff014a4240b5fd815f9c39f /src
parentb3a728d93f134684593576f8eaaf2daf8df39340 (diff)
Move <security:announceinvites> to core_channel.
Diffstat (limited to 'src')
-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
4 files changed, 35 insertions, 15 deletions
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);