Skip to content

Commit

Permalink
fix: stop blocked terms from showing up more than once (#5789)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Jan 4, 2025
1 parent 5aab424 commit 8b7d7f9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Bugfix: Fixed 7TV usernames messing with Qt's HTML (#5780)
- Bugfix: Fixed BTTV emotes occasionally showing the wrong author. (#5783)
- 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)

## 2.5.2-beta.1
Expand Down
10 changes: 6 additions & 4 deletions src/providers/twitch/TwitchIrcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,12 @@ void TwitchIrcServer::initialize()
PubSubAutoModQueueMessage::Reason::BlockedTerm)
{
auto numBlockedTermsMatched =
msg.blockedTermsFound.count();
msg.blockedTermsFound.size();
auto hideBlockedTerms =
getSettings()
->streamerModeHideBlockedTermText &&
getApp()->getStreamerMode()->isEnabled();
if (!msg.blockedTermsFound.isEmpty())
if (!msg.blockedTermsFound.empty())
{
if (hideBlockedTerms)
{
Expand All @@ -513,14 +513,16 @@ void TwitchIrcServer::initialize()
}
else
{
QStringList blockedTerms(
msg.blockedTermsFound.begin(),
msg.blockedTermsFound.end());
action.reason =
u"matches %1 blocked term%2 \"%3\""_s
.arg(numBlockedTermsMatched)
.arg(numBlockedTermsMatched > 1
? u"s"
: u"")
.arg(msg.blockedTermsFound.join(
u"\", \""));
.arg(blockedTerms.join(u"\", \""));
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion src/providers/twitch/pubsubmessages/AutoMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PubSubAutoModQueueMessage::PubSubAutoModQueueMessage(const QJsonObject &root)
const auto termText = term.value("text").toString();
if (!termText.isEmpty())
{
this->blockedTermsFound.push_back(termText);
this->blockedTermsFound.insert(termText);
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/providers/twitch/pubsubmessages/AutoMod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <QString>
#include <QStringList>

#include <set>

namespace chatterino {

struct PubSubAutoModQueueMessage {
Expand Down Expand Up @@ -41,7 +43,7 @@ struct PubSubAutoModQueueMessage {
QString senderUserDisplayName;
QColor senderUserChatColor;

QStringList blockedTermsFound;
std::set<QString> blockedTermsFound;

PubSubAutoModQueueMessage() = default;
explicit PubSubAutoModQueueMessage(const QJsonObject &root);
Expand Down

0 comments on commit 8b7d7f9

Please # to comment.