summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-01-09 19:58:43 +0000
committerPeter Powell <petpow@saberuk.com>2019-01-09 19:58:43 +0000
commitbe91435ccb8e05c84ecd126b5c41b74c45f4535b (patch)
tree6b04ccbfb88124e5681b3da2739aea74b62d9f61 /src
parentaea67c2520b9abbd3be702914b025e1b2a37e046 (diff)
core_privmsg: respect the exemption list when sending $* messages.
Diffstat (limited to 'src')
-rw-r--r--src/coremods/core_privmsg.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/coremods/core_privmsg.cpp b/src/coremods/core_privmsg.cpp
index dae770abe..692a661b3 100644
--- a/src/coremods/core_privmsg.cpp
+++ b/src/coremods/core_privmsg.cpp
@@ -95,12 +95,24 @@ class MessageCommandBase : public Command
ChanModeReference noextmsgmode;
/** Send a PRIVMSG or NOTICE message to all local users from the given user
- * @param user User sending the message
- * @param msg The message to send
- * @param mt Type of the message (MSG_PRIVMSG or MSG_NOTICE)
- * @param tags Message tags to include in the outgoing protocol message
+ * @param source The user sending the message.
+ * @param msg The details of the message to send.
*/
- static void SendAll(User* user, const std::string& msg, MessageType mt, const ClientProtocol::TagMap& tags);
+ static void SendAll(User* source, const MessageDetails& details)
+ {
+ ClientProtocol::Messages::Privmsg message(ClientProtocol::Messages::Privmsg::nocopy, source, "$*", details.text, details.type);
+ message.AddTags(details.tags_out);
+ message.SetSideEffect(true);
+ ClientProtocol::Event messageevent(ServerInstance->GetRFCEvents().privmsg, message);
+
+ const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
+ for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
+ {
+ LocalUser* user = *i;
+ if ((user->registered == REG_ALL) && (!details.exemptions.count(user)))
+ user->Send(messageevent);
+ }
+ }
public:
MessageCommandBase(Module* parent, MessageType mt)
@@ -128,21 +140,6 @@ class MessageCommandBase : public Command
}
};
-void MessageCommandBase::SendAll(User* user, const std::string& msg, MessageType mt, const ClientProtocol::TagMap& tags)
-{
- ClientProtocol::Messages::Privmsg message(ClientProtocol::Messages::Privmsg::nocopy, user, "$*", msg, mt);
- message.AddTags(tags);
- message.SetSideEffect(true);
- ClientProtocol::Event messageevent(ServerInstance->GetRFCEvents().privmsg, message);
-
- const UserManager::LocalList& list = ServerInstance->Users.GetLocalUsers();
- for (UserManager::LocalList::const_iterator i = list.begin(); i != list.end(); ++i)
- {
- if ((*i)->registered == REG_ALL)
- (*i)->Send(messageevent);
- }
-}
-
CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters, MessageType mt)
{
User *dest;
@@ -171,7 +168,7 @@ CmdResult MessageCommandBase::HandleMessage(User* user, const Params& parameters
FOREACH_MOD(OnUserMessage, (user, msgtarget, msgdetails));
if (InspIRCd::Match(ServerInstance->Config->ServerName, servername, NULL))
{
- SendAll(user, msgdetails.text, mt, msgdetails.tags_out);
+ SendAll(user, msgdetails);
}
FOREACH_MOD(OnUserPostMessage, (user, msgtarget, msgdetails));
return CMD_SUCCESS;