Skip to content

Commit

Permalink
chore: add suggested comments and warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy committed Dec 30, 2023
1 parent 2161285 commit 0a06bd6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
29 changes: 23 additions & 6 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ void Application::initPubSub()
std::ignore =
this->twitch->pubsub->signals_.moderation.suspiciousMessageReceived
.connect([&](const auto &action) {
if (action.treatment ==
PubSubLowTrustUsersMessage::Treatment::INVALID)
{
qCWarning(chatterinoTwitch)
<< "Received message with unknown suspicion: "
<< action.treatmentString;
return;
}

// monitored chats are received over irc; in the future, we will use pubsub instead
if (action.treatment !=
PubSubLowTrustUsersMessage::Treatment::Restricted)
{
Expand Down Expand Up @@ -509,9 +519,16 @@ void Application::initPubSub()
std::ignore =
this->twitch->pubsub->signals_.moderation.suspiciousTreatmentUpdated
.connect([&](const auto &action) {
if (action.updatedByUserLogin.isEmpty() ||
action.treatment ==
PubSubLowTrustUsersMessage::Treatment::INVALID)
if (action.treatment ==
PubSubLowTrustUsersMessage::Treatment::INVALID)
{
qCWarning(chatterinoTwitch)
<< "Suspicious user has unknown new treatment: "
<< action.treatmentString;
return;
}

if (action.updatedByUserLogin.isEmpty())
{
return;
}
Expand All @@ -529,9 +546,9 @@ void Application::initPubSub()
return;
}

auto msg =
TwitchMessageBuilder::makeLowTrustUpdateMessage(action);
postToThread([chan, msg] {
postToThread([chan, action] {
auto msg =
TwitchMessageBuilder::makeLowTrustUpdateMessage(action);
chan->addMessage(msg);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/providers/twitch/PubSubManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ void PubSub::handleMessageResponse(const PubSubMessageMessage &message)
break;

case PubSubLowTrustUsersMessage::Type::INVALID: {
qCDebug(chatterinoPubSub)
qCWarning(chatterinoPubSub)
<< "Invalid low trust users event type:"
<< innerMessage.typeString;
}
Expand Down
12 changes: 9 additions & 3 deletions src/providers/twitch/PubSubManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ class PubSub
/**
* Listen to moderation actions in the given channel.
* This topic is relevant for everyone.
* TODO: Briefly explain what's relevant for moderators & normal users.
* For moderators, this topic includes blocked/permitted terms updates,
* roomstate changes, general mod/vip updates, all bans/timeouts/deletions.
* For normal users, this topic includes moderation actions that are targetted at the local user:
* automod catching a user's sent message, a moderator approving or denying their caught messages,
* the user gaining/losing mod/vip, the user receiving a ban/timeout/deletion.
*
* PubSub topic: chat_moderator_actions.{currentUserID}.{channelID}
*/
Expand All @@ -153,15 +157,17 @@ class PubSub
* This will send events about incoming messages that
* are caught by Automod.
*
* PubSub topic: automod-queue.{channelID}.{currentUserID}
* PubSub topic: automod-queue.{currentUserID}.{channelID}
*/
void listenToAutomod(const QString &channelID);

/**
* Listen to Low Trust events in the given channel.
* This topic is only relevant for moderators.
* This will fire events about suspicious treatment updates
* and messages sent by restricted/monitored users.
*
* PubSub topic: low-trust-users.{channelID}.{currentUserID}
* PubSub topic: low-trust-users.{currentUserID}.{channelID}
*/
void listenToLowTrustUsers(const QString &channelID);

Expand Down

0 comments on commit 0a06bd6

Please sign in to comment.