]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Refactor OnUserPostMessage in the chanhistory module.
authorSadie Powell <sadie@witchery.services>
Wed, 24 Feb 2021 18:08:15 +0000 (18:08 +0000)
committerSadie Powell <sadie@witchery.services>
Wed, 24 Feb 2021 18:08:15 +0000 (18:08 +0000)
src/modules/m_chanhistory.cpp

index 4bd230a7c649c1278717696dcb84feb4efc6d7df..25110b4954f49be8ea3155b57e7a9493c8fa713f 100644 (file)
@@ -221,18 +221,20 @@ class ModuleChanHistory
 
        void OnUserPostMessage(User* user, const MessageTarget& target, const MessageDetails& details) CXX11_OVERRIDE
        {
+               if (target.type != MessageTarget::TYPE_CHANNEL || target.status)
+                       return;
+
                std::string ctcpname;
-               if ((target.type == MessageTarget::TYPE_CHANNEL) && (target.status == 0) && (!details.IsCTCP(ctcpname) || irc::equals(ctcpname, "ACTION")))
-               {
-                       Channel* c = target.Get<Channel>();
-                       HistoryList* list = historymode.ext.get(c);
-                       if (list)
-                       {
-                               list->lines.push_back(HistoryItem(user, details));
-                               if (list->lines.size() > list->maxlen)
-                                       list->lines.pop_front();
-                       }
-               }
+               if (details.IsCTCP(ctcpname) && !irc::equals(ctcpname, "ACTION"))
+                       return;
+
+               HistoryList* list = historymode.ext.get(target.Get<Channel>());
+               if (!list)
+                       return;
+
+               list->lines.push_back(HistoryItem(user, details));
+               if (list->lines.size() > list->maxlen)
+                       list->lines.pop_front();
        }
 
        void OnPostJoin(Membership* memb) CXX11_OVERRIDE