refactor(eventsub): Respect "Hide moderation actions" explicitly (#6041)

This commit is contained in:
pajlada
2025-03-08 14:00:35 +01:00
committed by GitHub
parent 0835064375
commit 77c4d858f9
79 changed files with 153 additions and 125 deletions
+9 -6
View File
@@ -431,9 +431,10 @@ void TwitchIrcServer::initialize()
return;
}
if (getSettings()->streamerModeHideModActions &&
getApp()->getStreamerMode()->isEnabled())
if (getApp()->getStreamerMode()->shouldHideModActions())
{
// NOTE: This completely stops the building of this action, rathern than only hiding it.
// If the user disabled streamer mode or the setting, there will be messages missing
return;
}
@@ -476,9 +477,10 @@ void TwitchIrcServer::initialize()
return;
}
if (getSettings()->streamerModeHideModActions &&
getApp()->getStreamerMode()->isEnabled())
if (getApp()->getStreamerMode()->shouldHideModActions())
{
// NOTE: This completely stops the building of this action, rathern than only hiding it.
// If the user disabled streamer mode or the setting, there will be messages missing
return;
}
@@ -680,9 +682,10 @@ void TwitchIrcServer::initialize()
this->connections_.managedConnect(
getApp()->getTwitchPubSub()->moderation.automodUserMessage,
[this](const auto &action) {
if (getSettings()->streamerModeHideModActions &&
getApp()->getStreamerMode()->isEnabled())
if (getApp()->getStreamerMode()->shouldHideModActions())
{
// NOTE: This completely stops the building of this action, rathern than only hiding it.
// If the user disabled streamer mode or the setting, there will be messages missing
return;
}
auto chan = this->getChannelOrEmptyByID(action.roomID);
@@ -281,12 +281,6 @@ void Connection::onChannelSuspiciousUserMessage(
return;
}
if (getSettings()->streamerModeHideModActions &&
getApp()->getStreamerMode()->isEnabled())
{
return;
}
auto *channel = dynamic_cast<TwitchChannel *>(
getApp()
->getTwitch()
@@ -143,7 +143,6 @@ EventSubMessageBuilder::EventSubMessageBuilder(TwitchChannel *channel,
{
this->emplace<TimestampElement>(time.time());
this->message().flags.set(MessageFlag::System, MessageFlag::EventSub);
this->message().flags.set(MessageFlag::Timeout); // do we need this?
this->message().serverReceivedTime = time;
}
@@ -217,6 +216,7 @@ void makeModerateMessage(EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Warn &action)
{
builder->flags.set(MessageFlag::ModerationAction);
QString text;
builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text);
@@ -255,6 +255,8 @@ void makeModerateMessage(EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Ban &action)
{
builder->flags.set(MessageFlag::ModerationAction, MessageFlag::Timeout);
QString text;
bool isShared = event.isFromSharedChat();
@@ -288,6 +290,8 @@ void makeModerateMessage(
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Unban &action)
{
builder->flags.set(MessageFlag::ModerationAction, MessageFlag::Untimeout);
QString text;
bool isShared = event.isFromSharedChat();
@@ -313,10 +317,11 @@ void makeModerateMessage(
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Untimeout &action)
{
builder->flags.set(MessageFlag::ModerationAction, MessageFlag::Untimeout);
QString text;
bool isShared = event.isFromSharedChat();
builder->flags.set(MessageFlag::Timeout);
builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text);
builder.emplaceSystemTextAndUpdate("untimedout", text);
builder.appendUser(action.userName, action.userLogin, text, isShared);
@@ -339,7 +344,8 @@ void makeModerateMessage(
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::Delete &action)
{
builder.message().flags.set(MessageFlag::DoNotTriggerNotification);
builder->flags.set(MessageFlag::DoNotTriggerNotification,
MessageFlag::ModerationAction);
QString text;
bool isShared = event.isFromSharedChat();
@@ -465,6 +471,8 @@ void makeModerateMessage(
const lib::payload::channel_moderate::v2::Event &event,
const lib::payload::channel_moderate::v2::AutomodTerms &action)
{
builder->flags.set(MessageFlag::ModerationAction);
QString text;
builder.appendUser(event.moderatorUserName, event.moderatorUserLogin, text);
@@ -589,7 +597,7 @@ MessagePtr makeAutomodHoldMessageHeader(
builder->id = u"automod_" % event.messageID.qt();
builder->loginName = u"automod"_s;
builder->channelName = event.broadcasterUserLogin.qt();
builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout,
builder->flags.set(MessageFlag::PubSub, MessageFlag::ModerationAction,
MessageFlag::AutoMod,
MessageFlag::AutoModOffendingMessageHeader);
builder->flags.set(
@@ -637,7 +645,7 @@ MessagePtr makeAutomodHoldMessageBody(
{
EventSubMessageBuilder builder(channel);
builder->serverReceivedTime = time;
builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout,
builder->flags.set(MessageFlag::PubSub, MessageFlag::ModerationAction,
MessageFlag::AutoMod,
MessageFlag::AutoModOffendingMessage);
builder->flags.set(
@@ -784,7 +792,8 @@ MessagePtr makeSuspiciousUserUpdate(
const lib::payload::channel_suspicious_user_update::v1::Event &event)
{
EventSubMessageBuilder builder(channel, time);
builder->flags.set(MessageFlag::DoNotTriggerNotification);
builder->flags.set(MessageFlag::DoNotTriggerNotification,
MessageFlag::ModerationAction);
builder->loginName = event.moderatorUserLogin.qt();
QString text;
@@ -833,8 +842,7 @@ MessagePtr makeUserMessageHeldMessage(
builder->id = u"automod_" % event.messageID.qt();
builder->loginName = u"automod"_s;
builder->channelName = event.broadcasterUserLogin.qt();
builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout,
MessageFlag::AutoMod);
builder->flags.set(MessageFlag::PubSub, MessageFlag::AutoMod);
// AutoMod shield badge
builder.emplace<BadgeElement>(makeAutoModBadge(),
@@ -863,8 +871,7 @@ MessagePtr makeUserMessageUpdateMessage(
builder->id = u"automod_" % event.messageID.qt();
builder->loginName = u"automod"_s;
builder->channelName = event.broadcasterUserLogin.qt();
builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout,
MessageFlag::AutoMod);
builder->flags.set(MessageFlag::PubSub, MessageFlag::AutoMod);
// AutoMod shield badge
builder.emplace<BadgeElement>(makeAutoModBadge(),
@@ -45,7 +45,8 @@ void handleModerateMessage(
EventSubMessageBuilder builder(chan, time);
builder->loginName = event.moderatorUserLogin.qt();
// pretend we're pubsub
builder->flags.set(MessageFlag::PubSub);
builder->flags.set(MessageFlag::PubSub, MessageFlag::Timeout,
MessageFlag::ModerationAction);
QString text;
bool isShared = event.isFromSharedChat();