From 52a6f259cff60d8827c7944dd4bccc1e9cc109f8 Mon Sep 17 00:00:00 2001 From: 2547techno <109011672+2547techno@users.noreply.github.com> Date: Thu, 13 Apr 2023 12:13:49 -0400 Subject: [PATCH] Fix: check reply-parent-user-id for blocked user (#4502) --- CHANGELOG.md | 1 + src/providers/twitch/TwitchMessageBuilder.cpp | 33 +++++++++++++++---- src/providers/twitch/TwitchMessageBuilder.hpp | 1 + 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 535af2305..b63d780e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Minor: Added the ability to reply to a message by `Shift + Right Click`ing the username. (#4424) - Minor: Added better filter validation and error messages. (#4364) - Minor: Updated the look of the Black Theme to be more in line with the other themes. (#4523) +- Minor: Reply context now censors blocked users. (#4502) - Bugfix: Fixed an issue where animated emotes would render on top of zero-width emotes. (#4314) - Bugfix: Fixed an issue where it was difficult to hover a zero-width emote. (#4314) - Bugfix: Fixed an issue where context-menu items for zero-width emotes displayed the wrong provider. (#4460) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 3cf157c54..ab95cebc0 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -157,6 +157,17 @@ bool TwitchMessageBuilder::isIgnored() const }); } +bool TwitchMessageBuilder::isIgnoredReply() const +{ + return isIgnoredMessage({ + /*.message = */ this->originalMessage_, + /*.twitchUserID = */ + this->tags.value("reply-parent-user-id").toString(), + /*.isMod = */ this->channel->isMod(), + /*.isBroadcaster = */ this->channel->isBroadcaster(), + }); +} + void TwitchMessageBuilder::triggerHighlights() { if (this->historicalMessage_) @@ -622,19 +633,27 @@ void TwitchMessageBuilder::parseThread() if (replyDisplayName != this->tags.end() && replyBody != this->tags.end()) { - auto name = replyDisplayName->toString(); - auto body = parseTagString(replyBody->toString()); + QString body; this->emplace(); - this->emplace( "Replying to", MessageElementFlag::RepliedMessage, MessageColor::System, FontStyle::ChatMediumSmall); - this->emplace( - "@" + name + ":", MessageElementFlag::RepliedMessage, - this->textColor_, FontStyle::ChatMediumSmall) - ->setLink({Link::UserInfo, name}); + if (this->isIgnoredReply()) + { + body = QString("[Blocked user]"); + } + else + { + auto name = replyDisplayName->toString(); + body = parseTagString(replyBody->toString()); + + this->emplace( + "@" + name + ":", MessageElementFlag::RepliedMessage, + this->textColor_, FontStyle::ChatMediumSmall) + ->setLink({Link::UserInfo, name}); + } this->emplace( body, diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index c866d9675..480e18688 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -53,6 +53,7 @@ public: TwitchChannel *twitchChannel; [[nodiscard]] bool isIgnored() const override; + bool isIgnoredReply() const; void triggerHighlights() override; MessagePtr build() override;