From 1e1b015cf08bebd8ee07fc9e6361f5d33d7bc2d7 Mon Sep 17 00:00:00 2001 From: 2547techno Date: Sun, 2 Apr 2023 16:44:56 -0400 Subject: [PATCH] censor parent message if from blocked user --- src/providers/twitch/TwitchMessageBuilder.cpp | 22 ++++++++++++++++++- src/providers/twitch/TwitchMessageBuilder.hpp | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 3cf157c5488..7fc30c5fcc2 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -157,6 +157,18 @@ 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_) @@ -623,7 +635,15 @@ void TwitchMessageBuilder::parseThread() replyBody != this->tags.end()) { auto name = replyDisplayName->toString(); - auto body = parseTagString(replyBody->toString()); + QString body; + if (this->isIgnoredReply()) + { + body = QString("*Blocked message*"); + } + else + { + body = parseTagString(replyBody->toString()); + } this->emplace(); diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index c866d967596..480e18688fd 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -53,6 +53,7 @@ class TwitchMessageBuilder : public SharedMessageBuilder TwitchChannel *twitchChannel; [[nodiscard]] bool isIgnored() const override; + bool isIgnoredReply() const; void triggerHighlights() override; MessagePtr build() override;