fix: stop blocked terms from showing up more than once (#5789)

This commit is contained in:
pajlada
2025-01-04 12:57:09 +01:00
committed by GitHub
parent 5aab424a6a
commit 8b7d7f9d71
4 changed files with 11 additions and 6 deletions
+1
View File
@@ -8,6 +8,7 @@
- Bugfix: Fixed 7TV usernames messing with Qt's HTML (#5780) - Bugfix: Fixed 7TV usernames messing with Qt's HTML (#5780)
- Bugfix: Fixed BTTV emotes occasionally showing the wrong author. (#5783) - Bugfix: Fixed BTTV emotes occasionally showing the wrong author. (#5783)
- Bugfix: Fixed some Twitch emotes containing HTML entities. (#5786) - Bugfix: Fixed some Twitch emotes containing HTML entities. (#5786)
- Bugfix: Fixed the same blocked term showing up more than once. (#5789)
- Dev: Hard-code Boost 1.86.0 in macos CI builders. (#5774) - Dev: Hard-code Boost 1.86.0 in macos CI builders. (#5774)
## 2.5.2-beta.1 ## 2.5.2-beta.1
+6 -4
View File
@@ -495,12 +495,12 @@ void TwitchIrcServer::initialize()
PubSubAutoModQueueMessage::Reason::BlockedTerm) PubSubAutoModQueueMessage::Reason::BlockedTerm)
{ {
auto numBlockedTermsMatched = auto numBlockedTermsMatched =
msg.blockedTermsFound.count(); msg.blockedTermsFound.size();
auto hideBlockedTerms = auto hideBlockedTerms =
getSettings() getSettings()
->streamerModeHideBlockedTermText && ->streamerModeHideBlockedTermText &&
getApp()->getStreamerMode()->isEnabled(); getApp()->getStreamerMode()->isEnabled();
if (!msg.blockedTermsFound.isEmpty()) if (!msg.blockedTermsFound.empty())
{ {
if (hideBlockedTerms) if (hideBlockedTerms)
{ {
@@ -513,14 +513,16 @@ void TwitchIrcServer::initialize()
} }
else else
{ {
QStringList blockedTerms(
msg.blockedTermsFound.begin(),
msg.blockedTermsFound.end());
action.reason = action.reason =
u"matches %1 blocked term%2 \"%3\""_s u"matches %1 blocked term%2 \"%3\""_s
.arg(numBlockedTermsMatched) .arg(numBlockedTermsMatched)
.arg(numBlockedTermsMatched > 1 .arg(numBlockedTermsMatched > 1
? u"s" ? u"s"
: u"") : u"")
.arg(msg.blockedTermsFound.join( .arg(blockedTerms.join(u"\", \""));
u"\", \""));
} }
} }
else else
@@ -60,7 +60,7 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
const auto termText = term.value("text").toString(); const auto termText = term.value("text").toString();
if (!termText.isEmpty()) if (!termText.isEmpty())
{ {
this->blockedTermsFound.push_back(termText); this->blockedTermsFound.insert(termText);
} }
} }
} }
@@ -6,6 +6,8 @@
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <set>
namespace chatterino { namespace chatterino {
struct PubSubAutoModQueueMessage { struct PubSubAutoModQueueMessage {
@@ -41,7 +43,7 @@ struct PubSubAutoModQueueMessage {
QString senderUserDisplayName; QString senderUserDisplayName;
QColor senderUserChatColor; QColor senderUserChatColor;
QStringList blockedTermsFound; std::set<QString> blockedTermsFound;
PubSubAutoModQueueMessage() = default; PubSubAutoModQueueMessage() = default;
explicit PubSubAutoModQueueMessage(const QJsonObject &root); explicit PubSubAutoModQueueMessage(const QJsonObject &root);