]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_ircv3_ctctags.cpp
Make connect class debug logging more complete and consistent.
[user/henk/code/inspircd.git] / src / modules / m_ircv3_ctctags.cpp
index d0012b75279c112e1cb2e86abc2e1d8459376b12..2856579870839a2441b0f2a0b9e9b466ce932ad3 100644 (file)
@@ -2,7 +2,7 @@
  * InspIRCd -- Internet Relay Chat Daemon
  *
  *   Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
- *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018-2020 Sadie Powell <sadie@witchery.services>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -57,7 +57,7 @@ class CommandTagMsg : public Command
        {
                // If the source is local then update its idle time.
                LocalUser* lsource = IS_LOCAL(source);
-               if (lsource)
+               if (lsource && msgdetails.update_idle)
                        lsource->idle_lastmsg = ServerInstance->Time();
 
                // Inform modules that a TAGMSG was sent.
@@ -82,14 +82,14 @@ class CommandTagMsg : public Command
                        return CMD_FAILURE;
 
                unsigned int minrank = pm ? pm->GetPrefixRank() : 0;
-               CTCTags::TagMessage message(source, chan, msgdetails.tags_out);
+               CTCTags::TagMessage message(source, chan, msgdetails.tags_out, msgtarget.status);
                message.SetSideEffect(true);
                const Channel::MemberMap& userlist = chan->GetUsers();
                for (Channel::MemberMap::const_iterator iter = userlist.begin(); iter != userlist.end(); ++iter)
                {
                        LocalUser* luser = IS_LOCAL(iter->first);
 
-                       // Don't send to remote users or the user who is the source. 
+                       // Don't send to remote users or the user who is the source.
                        if (!luser || luser == source)
                                continue;
 
@@ -109,7 +109,10 @@ class CommandTagMsg : 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);
@@ -261,6 +264,7 @@ class C2CTags : public ClientProtocol::MessageTagProvider
        Cap::Capability& cap;
 
  public:
+       bool allowclientonlytags;
        C2CTags(Module* Creator, Cap::Capability& Cap)
                : ClientProtocol::MessageTagProvider(Creator)
                , cap(Cap)
@@ -271,7 +275,7 @@ class C2CTags : public ClientProtocol::MessageTagProvider
        {
                // A client-only tag is prefixed with a plus sign (+) and otherwise conforms
                // to the format specified in IRCv3.2 tags.
-               if (tagname[0] != '+' || tagname.length() < 2)
+               if (tagname[0] != '+' || tagname.length() < 2 || !allowclientonlytags)
                        return MOD_RES_PASSTHRU;
 
                // If the user is local then we check whether they have the message-tags cap
@@ -323,6 +327,17 @@ class ModuleIRCv3CTCTags
        {
        }
 
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+       {
+               c2ctags.allowclientonlytags = ServerInstance->Config->ConfValue("ctctags")->getBool("allowclientonlytags", true);
+       }
+
+       void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
+       {
+               if (!c2ctags.allowclientonlytags)
+                       tokens["CLIENTTAGDENY"] = "*";
+       }
+
        ModResult OnUserPreMessage(User* user, const MessageTarget& target, MessageDetails& details) CXX11_OVERRIDE
        {
                return CopyClientTags(details.tags_in, details.tags_out);
@@ -336,7 +351,7 @@ class ModuleIRCv3CTCTags
                        if (chan->IsModeSet(noextmsgmode) && !chan->HasUser(user))
                        {
                                // The noextmsg mode is set and the user is not in the channel.
-                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (no external messages)");
+                               user->WriteNumeric(Numerics::CannotSendTo(chan, "external messages", *noextmsgmode));
                                return MOD_RES_DENY;
                        }
 
@@ -344,7 +359,7 @@ class ModuleIRCv3CTCTags
                        if (no_chan_priv && chan->IsModeSet(moderatedmode))
                        {
                                // The moderated mode is set and the user has no status rank.
-                               user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (+m is set)");
+                               user->WriteNumeric(Numerics::CannotSendTo(chan, "messages", *noextmsgmode));
                                return MOD_RES_DENY;
                        }
 
@@ -352,7 +367,7 @@ class ModuleIRCv3CTCTags
                        {
                                // The user is banned in the channel and restrictbannedusers is enabled.
                                if (ServerInstance->Config->RestrictBannedUsers == ServerConfig::BUT_RESTRICT_NOTIFY)
-                                       user->WriteNumeric(ERR_CANNOTSENDTOCHAN, chan->name, "Cannot send to channel (you're banned)");
+                                       user->WriteNumeric(Numerics::CannotSendTo(chan, "You cannot send messages to this channel whilst banned."));
                                return MOD_RES_DENY;
                        }
                }
@@ -362,7 +377,7 @@ class ModuleIRCv3CTCTags
 
        Version GetVersion() CXX11_OVERRIDE
        {
-               return Version("Provides the message-tags IRCv3 extension", VF_VENDOR | VF_COMMON);
+               return Version("Provides the IRCv3 message-tags client capability.", VF_VENDOR | VF_COMMON);
        }
 };