diff options
author | linuxdaemon <linuxdaemon@users.noreply.github.com> | 2019-06-24 11:10:17 -0500 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-06-24 17:10:17 +0100 |
commit | 7ad534c1af4578a0d46742c4b6b00a5a33afb63f (patch) | |
tree | dacfcae9d65803a1aaa5941588b016f56be10e79 /src/modules/m_silence.cpp | |
parent | 2ab383f707ec648ceeb29059ce4f54d4bbb056a4 (diff) |
Replace large if/else blocks for target.type with switches (#1668).
Diffstat (limited to 'src/modules/m_silence.cpp')
-rw-r--r-- | src/modules/m_silence.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 87b70dfa4..1e73bda27 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -384,32 +384,38 @@ class ModuleSilence bool is_ctcp = details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION"); SilenceEntry::SilenceFlags flag = SilenceEntry::SF_NONE; - if (target.type == MessageTarget::TYPE_CHANNEL) - { - if (is_ctcp) - flag = SilenceEntry::SF_CTCP_CHANNEL; - else if (details.type == MSG_NOTICE) - flag = SilenceEntry::SF_NOTICE_CHANNEL; - else if (details.type == MSG_PRIVMSG) - flag = SilenceEntry::SF_PRIVMSG_CHANNEL; - - return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions); - } - - if (target.type == MessageTarget::TYPE_USER) + switch (target.type) { - if (is_ctcp) - flag = SilenceEntry::SF_CTCP_USER; - else if (details.type == MSG_NOTICE) - flag = SilenceEntry::SF_NOTICE_USER; - else if (details.type == MSG_PRIVMSG) - flag = SilenceEntry::SF_PRIVMSG_USER; - - if (!CanReceiveMessage(user, target.Get<User>(), flag)) + case MessageTarget::TYPE_CHANNEL: + { + if (is_ctcp) + flag = SilenceEntry::SF_CTCP_CHANNEL; + else if (details.type == MSG_NOTICE) + flag = SilenceEntry::SF_NOTICE_CHANNEL; + else if (details.type == MSG_PRIVMSG) + flag = SilenceEntry::SF_PRIVMSG_CHANNEL; + + return BuildChannelExempts(user, target.Get<Channel>(), flag, details.exemptions); + break; + } + case MessageTarget::TYPE_USER: { - details.echo_original = true; - return MOD_RES_DENY; + if (is_ctcp) + flag = SilenceEntry::SF_CTCP_USER; + else if (details.type == MSG_NOTICE) + flag = SilenceEntry::SF_NOTICE_USER; + else if (details.type == MSG_PRIVMSG) + flag = SilenceEntry::SF_PRIVMSG_USER; + + if (!CanReceiveMessage(user, target.Get<User>(), flag)) + { + details.echo_original = true; + return MOD_RES_DENY; + } + break; } + case MessageTarget::TYPE_SERVER: + break; } return MOD_RES_PASSTHRU; |