From 5860247c3bf664daac1234f47f68ed30402fe13d Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 24 Feb 2021 18:08:15 +0000 Subject: Refactor OnUserPostMessage in the chanhistory module. --- src/modules/m_chanhistory.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 4bd230a7c..25110b495 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -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(); - 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()); + 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 -- cgit v1.2.3