mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: notify mods when users are warned (#5441)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
248cd46eb7
commit
d2316af70f
|
@ -9,6 +9,7 @@
|
||||||
- Minor: Added `flags.action` filter variable, allowing you to filter on `/me` messages. (#5397)
|
- Minor: Added `flags.action` filter variable, allowing you to filter on `/me` messages. (#5397)
|
||||||
- Minor: The size of the emote popup is now saved. (#5415)
|
- Minor: The size of the emote popup is now saved. (#5415)
|
||||||
- Minor: Added the ability to duplicate tabs. (#5277)
|
- Minor: Added the ability to duplicate tabs. (#5277)
|
||||||
|
- Minor: Moderators can now see when users are warned. (#5441)
|
||||||
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
||||||
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
||||||
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
||||||
|
|
|
@ -650,6 +650,24 @@ void Application::initPubSub()
|
||||||
chan->addOrReplaceTimeout(msg.release());
|
chan->addOrReplaceTimeout(msg.release());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
std::ignore = this->twitchPubSub->moderation.userWarned.connect(
|
||||||
|
[&](const auto &action) {
|
||||||
|
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
||||||
|
if (chan->isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Resolve the moderator's user ID into a full user here, so message can look better
|
||||||
|
postToThread([chan, action] {
|
||||||
|
MessageBuilder msg(action);
|
||||||
|
msg->flags.set(MessageFlag::PubSub);
|
||||||
|
chan->addMessage(msg.release());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
std::ignore = this->twitchPubSub->moderation.messageDeleted.connect(
|
std::ignore = this->twitchPubSub->moderation.messageDeleted.connect(
|
||||||
[&](const auto &action) {
|
[&](const auto &action) {
|
||||||
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
|
auto chan = this->twitch->getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
|
@ -323,6 +323,31 @@ MessageBuilder::MessageBuilder(const UnbanAction &action)
|
||||||
this->message().searchText = text;
|
this->message().searchText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageBuilder::MessageBuilder(const WarnAction &action)
|
||||||
|
: MessageBuilder()
|
||||||
|
{
|
||||||
|
this->emplace<TimestampElement>();
|
||||||
|
this->message().flags.set(MessageFlag::System);
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
// TODO: Use MentionElement here, once WarnAction includes username/displayname
|
||||||
|
this->emplaceSystemTextAndUpdate("A moderator", text)
|
||||||
|
->setLink({Link::UserInfo, "id:" + action.source.id});
|
||||||
|
this->emplaceSystemTextAndUpdate("warned", text);
|
||||||
|
this->emplaceSystemTextAndUpdate(
|
||||||
|
action.target.login + (action.reasons.isEmpty() ? "." : ":"), text)
|
||||||
|
->setLink({Link::UserInfo, action.target.login});
|
||||||
|
|
||||||
|
if (!action.reasons.isEmpty())
|
||||||
|
{
|
||||||
|
this->emplaceSystemTextAndUpdate(action.reasons.join(", "), text);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->message().messageText = text;
|
||||||
|
this->message().searchText = text;
|
||||||
|
}
|
||||||
|
|
||||||
MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
||||||
: MessageBuilder()
|
: MessageBuilder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
struct BanAction;
|
struct BanAction;
|
||||||
struct UnbanAction;
|
struct UnbanAction;
|
||||||
|
struct WarnAction;
|
||||||
struct AutomodAction;
|
struct AutomodAction;
|
||||||
struct AutomodUserAction;
|
struct AutomodUserAction;
|
||||||
struct AutomodInfoAction;
|
struct AutomodInfoAction;
|
||||||
|
@ -78,6 +79,7 @@ public:
|
||||||
const QTime &time = QTime::currentTime());
|
const QTime &time = QTime::currentTime());
|
||||||
MessageBuilder(const BanAction &action, uint32_t count = 1);
|
MessageBuilder(const BanAction &action, uint32_t count = 1);
|
||||||
MessageBuilder(const UnbanAction &action);
|
MessageBuilder(const UnbanAction &action);
|
||||||
|
MessageBuilder(const WarnAction &action);
|
||||||
MessageBuilder(const AutomodUserAction &action);
|
MessageBuilder(const AutomodUserAction &action);
|
||||||
|
|
||||||
MessageBuilder(LiveUpdatesAddEmoteMessageTag, const QString &platform,
|
MessageBuilder(LiveUpdatesAddEmoteMessageTag, const QString &platform,
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
@ -171,4 +172,12 @@ struct AutomodInfoAction : PubSubAction {
|
||||||
} type;
|
} type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct WarnAction : PubSubAction {
|
||||||
|
using PubSubAction::PubSubAction;
|
||||||
|
|
||||||
|
ActionUser target;
|
||||||
|
|
||||||
|
QStringList reasons;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -286,6 +286,37 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
||||||
this->moderation.userUnbanned.invoke(action);
|
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 handler is no longer required as we use the automod-queue topic now
|
||||||
this->moderationActionHandlers["automod_rejected"] =
|
this->moderationActionHandlers["automod_rejected"] =
|
||||||
|
@ -1131,8 +1162,8 @@ void PubSub::handleMessageResponse(const PubSubMessageMessage &message)
|
||||||
|
|
||||||
case PubSubChatModeratorActionMessage::Type::INVALID:
|
case PubSubChatModeratorActionMessage::Type::INVALID:
|
||||||
default: {
|
default: {
|
||||||
qCDebug(chatterinoPubSub)
|
qCDebug(chatterinoPubSub) << "Invalid moderator action type:"
|
||||||
<< "Invalid whisper type:" << innerMessage.typeString;
|
<< innerMessage.typeString;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ struct PubSubAutoModQueueMessage;
|
||||||
struct AutomodAction;
|
struct AutomodAction;
|
||||||
struct AutomodUserAction;
|
struct AutomodUserAction;
|
||||||
struct AutomodInfoAction;
|
struct AutomodInfoAction;
|
||||||
|
struct WarnAction;
|
||||||
struct PubSubLowTrustUsersMessage;
|
struct PubSubLowTrustUsersMessage;
|
||||||
struct PubSubWhisperMessage;
|
struct PubSubWhisperMessage;
|
||||||
|
|
||||||
|
@ -97,6 +98,7 @@ public:
|
||||||
|
|
||||||
Signal<BanAction> userBanned;
|
Signal<BanAction> userBanned;
|
||||||
Signal<UnbanAction> userUnbanned;
|
Signal<UnbanAction> userUnbanned;
|
||||||
|
Signal<WarnAction> userWarned;
|
||||||
|
|
||||||
Signal<PubSubLowTrustUsersMessage> suspiciousMessageReceived;
|
Signal<PubSubLowTrustUsersMessage> suspiciousMessageReceived;
|
||||||
Signal<PubSubLowTrustUsersMessage> suspiciousTreatmentUpdated;
|
Signal<PubSubLowTrustUsersMessage> suspiciousTreatmentUpdated;
|
||||||
|
|
Loading…
Reference in a new issue