feat: notify mods when users are warned (#5441)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <chrono>
|
||||
#include <cinttypes>
|
||||
@@ -171,4 +172,12 @@ struct AutomodInfoAction : PubSubAction {
|
||||
} type;
|
||||
};
|
||||
|
||||
struct WarnAction : PubSubAction {
|
||||
using PubSubAction::PubSubAction;
|
||||
|
||||
ActionUser target;
|
||||
|
||||
QStringList reasons;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -286,6 +286,37 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
||||
this->moderation.userUnbanned.invoke(action);
|
||||
};
|
||||
|
||||
this->moderationActionHandlers["warn"] = [this](const auto &data,
|
||||
const auto &roomID) {
|
||||
WarnAction action(data, roomID);
|
||||
|
||||
action.source.id = data.value("created_by_user_id").toString();
|
||||
action.source.login =
|
||||
data.value("created_by").toString(); // currently always empty
|
||||
|
||||
action.target.id = data.value("target_user_id").toString();
|
||||
action.target.login = data.value("target_user_login").toString();
|
||||
|
||||
const auto reasons = data.value("args").toArray();
|
||||
bool firstArg = true;
|
||||
for (const auto &reasonValue : reasons)
|
||||
{
|
||||
if (firstArg)
|
||||
{
|
||||
// Skip first arg in the reasons array since it's not a reason
|
||||
firstArg = false;
|
||||
continue;
|
||||
}
|
||||
const auto &reason = reasonValue.toString();
|
||||
if (!reason.isEmpty())
|
||||
{
|
||||
action.reasons.append(reason);
|
||||
}
|
||||
}
|
||||
|
||||
this->moderation.userWarned.invoke(action);
|
||||
};
|
||||
|
||||
/*
|
||||
// This handler is no longer required as we use the automod-queue topic now
|
||||
this->moderationActionHandlers["automod_rejected"] =
|
||||
@@ -1131,8 +1162,8 @@ void PubSub::handleMessageResponse(const PubSubMessageMessage &message)
|
||||
|
||||
case PubSubChatModeratorActionMessage::Type::INVALID:
|
||||
default: {
|
||||
qCDebug(chatterinoPubSub)
|
||||
<< "Invalid whisper type:" << innerMessage.typeString;
|
||||
qCDebug(chatterinoPubSub) << "Invalid moderator action type:"
|
||||
<< innerMessage.typeString;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ struct PubSubAutoModQueueMessage;
|
||||
struct AutomodAction;
|
||||
struct AutomodUserAction;
|
||||
struct AutomodInfoAction;
|
||||
struct WarnAction;
|
||||
struct PubSubLowTrustUsersMessage;
|
||||
struct PubSubWhisperMessage;
|
||||
|
||||
@@ -97,6 +98,7 @@ public:
|
||||
|
||||
Signal<BanAction> userBanned;
|
||||
Signal<UnbanAction> userUnbanned;
|
||||
Signal<WarnAction> userWarned;
|
||||
|
||||
Signal<PubSubLowTrustUsersMessage> suspiciousMessageReceived;
|
||||
Signal<PubSubLowTrustUsersMessage> suspiciousTreatmentUpdated;
|
||||
|
||||
Reference in New Issue
Block a user