feat: Hide messages from suspicious users in streamer mode (#6042)

This is a setting that's enabled by default and can be disabled under
the "Streamer mode" sub-category in the settings dialog
This commit is contained in:
pajlada
2025-03-08 15:10:25 +01:00
committed by GitHub
parent 9913c6ffd7
commit ee266c35a7
11 changed files with 49 additions and 2 deletions
+11
View File
@@ -166,6 +166,17 @@ void MessageLayout::actuallyLayout(const MessageLayoutContext &ctx)
continue;
}
if (this->message_->flags.hasAny(MessageFlag::RestrictedMessage,
MessageFlag::MonitoredMessage))
{
if (getApp()->getStreamerMode()->shouldHideSuspiciousUsers())
{
// Message is being hidden because the source is a
// restricted or monitored user
continue;
}
}
if (this->message_->flags.has(MessageFlag::ModerationAction))
{
if (hideModerationActions ||
@@ -704,10 +704,12 @@ MessagePtr makeSuspiciousUserMessageHeader(
if (event.lowTrustStatus == lib::suspicious_users::Status::Restricted)
{
headerMessage = u"Restricted"_s;
builder->flags.set(MessageFlag::RestrictedMessage);
}
else
{
headerMessage = u"Monitored"_s;
builder->flags.set(MessageFlag::MonitoredMessage);
}
auto hasType = [&](lib::suspicious_users::Type type) {
+10
View File
@@ -346,6 +346,12 @@ public:
BoolSetting lowercaseDomains = {"/links/linkLowercase", true};
/// Streamer Mode
// TODO: Should these settings be converted to booleans that live outside of
// streamer mode?
// Something like:
// - "Hide when streamer mode is enabled"
// - "Always hide"
// - "Don't hide"
EnumSetting<StreamerModeSetting> enableStreamerMode = {
"/streamerMode/enabled", StreamerModeSetting::DetectStreamingSoftware};
BoolSetting streamerModeHideUsercardAvatars = {
@@ -356,6 +362,10 @@ public:
"/streamerMode/hideViewerCountAndDuration", false};
BoolSetting streamerModeHideModActions = {"/streamerMode/hideModActions",
true};
BoolSetting streamerModeHideSuspiciousUsers = {
"/streamerMode/hideSuspiciousUsers",
true,
};
BoolSetting streamerModeMuteMentions = {"/streamerMode/muteMentions", true};
BoolSetting streamerModeSuppressLiveNotifications = {
"/streamerMode/supressLiveNotifications", false};
+5
View File
@@ -207,6 +207,11 @@ bool StreamerMode::shouldHideModActions() const
return getSettings()->streamerModeHideModActions && this->isEnabled();
}
bool StreamerMode::shouldHideSuspiciousUsers() const
{
return getSettings()->streamerModeHideSuspiciousUsers && this->isEnabled();
}
void StreamerMode::start()
{
this->private_->start();
+4
View File
@@ -23,6 +23,9 @@ public:
/// Returns true if streamer mode is enabled & the settings to hide mod actions is enabled
[[nodiscard]] virtual bool shouldHideModActions() const = 0;
/// Returns true if streamer mode is enabled & the settings to hide messages from suspicious users is enabled
[[nodiscard]] virtual bool shouldHideSuspiciousUsers() const = 0;
virtual void start() = 0;
Q_SIGNALS:
@@ -43,6 +46,7 @@ public:
bool isEnabled() const override;
bool shouldHideModActions() const override;
bool shouldHideSuspiciousUsers() const override;
void start() override;
+2
View File
@@ -147,6 +147,8 @@ WindowManager::WindowManager(const Paths &paths, Settings &settings,
this->forceLayoutChannelViewsListener.add(settings.hideModerated);
this->forceLayoutChannelViewsListener.add(
settings.streamerModeHideModActions);
this->forceLayoutChannelViewsListener.add(
settings.streamerModeHideSuspiciousUsers);
this->layoutChannelViewsListener.add(settings.timestampFormat);
this->layoutChannelViewsListener.add(fonts.fontChanged);
@@ -732,6 +732,13 @@ void GeneralPage::initLayout(GeneralPageView &layout)
layout.addCheckbox(
"Hide moderation actions", s.streamerModeHideModActions, false,
"Hide bans, timeouts, and automod messages from appearing in chat.");
SettingWidget::checkbox("Hide messages from suspicious users",
s.streamerModeHideSuspiciousUsers)
->setTooltip("Suspicious users are users who are marked as either "
"restricted or monitored by you or Twitch's AutoMod")
->addTo(layout);
layout.addCheckbox(
"Hide blocked terms", s.streamerModeHideBlockedTermText, false,
"Hide blocked terms from showing up in places like AutoMod messages. "