]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_message.cpp
Fix the numeric sent when a U-lined alias target is not online.
[user/henk/code/inspircd.git] / src / coremods / core_message.cpp
index 585e299486d0bdf6653b546640edea040863ad5d..75abd69005966db91c05634429b644b4582da21d 100644 (file)
 
 #include "inspircd.h"
 
-enum
-{
-       // From RFC 2812.
-       ERR_NOSUCHSERVICE = 408
-};
 
 class MessageDetailsImpl : public MessageDetails
 {
@@ -174,7 +169,10 @@ class CommandMessage : public Command
                // If the source isn't allowed to mass message users then reject
                // the attempt to mass-message users.
                if (!source->HasPrivPermission("users/mass-message"))
+               {
+                       source->WriteNumeric(ERR_NOPRIVILEGES, "Permission Denied - You do not have the required operator privileges");
                        return CMD_FAILURE;
+               }
 
                // Extract the server glob match from the target parameter.
                std::string servername(parameters[0], 1);
@@ -247,21 +245,21 @@ class CommandMessage : public Command
                        return CMD_FAILURE;
                }
 
-               // If the target is away then inform the user.
-               if (target->IsAway() && msgtype == MSG_PRIVMSG)
-                       source->WriteNumeric(RPL_AWAY, target->nick, target->awaymsg);
-
                // Fire the pre-message events.
                MessageTarget msgtarget(target);
                MessageDetailsImpl msgdetails(msgtype, parameters[1], parameters.GetTags());
                if (!FirePreEvents(source, msgtarget, msgdetails))
                        return CMD_FAILURE;
 
+               // If the target is away then inform the user.
+               if (target->IsAway() && msgdetails.type == MSG_PRIVMSG)
+                       source->WriteNumeric(RPL_AWAY, target->nick, target->awaymsg);
+
                LocalUser* const localtarget = IS_LOCAL(target);
                if (localtarget)
                {
                        // Send to the target if they are a local user.
-                       ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, source, localtarget->nick, msgdetails.text, msgtype);
+                       ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, source, localtarget->nick, msgdetails.text, msgdetails.type);
                        privmsg.AddTags(msgdetails.tags_out);
                        privmsg.SetSideEffect(true);
                        localtarget->Send(ServerInstance->GetRFCEvents().privmsg, privmsg);