Move <security:announceinvites> to core_channel.

This commit is contained in:
Peter Powell 2018-03-31 13:02:57 +01:00
parent b3a728d93f
commit 802eed1734
5 changed files with 36 additions and 23 deletions

View File

@ -257,9 +257,6 @@ 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,
* it's indexed by tag name to a vector of key/values.
*/
@ -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;

View File

@ -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

View File

@ -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))

View File

@ -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;

View File

@ -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);