mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Only listen to new pubsub "moderator added" syntax (#1659)
This commit is contained in:
parent
7719816891
commit
ef9c631c65
|
@ -347,30 +347,31 @@ PubSub::PubSub()
|
||||||
this->moderationActionHandlers["mod"] = [this](const auto &data,
|
this->moderationActionHandlers["mod"] = [this](const auto &data,
|
||||||
const auto &roomID) {
|
const auto &roomID) {
|
||||||
ModerationStateAction action(data, roomID);
|
ModerationStateAction action(data, roomID);
|
||||||
|
|
||||||
getTargetUser(data, action.target);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
const auto &args = getArgs(data);
|
|
||||||
|
|
||||||
if (args.Size() < 1)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!rj::getSafe(args[0], action.target.name))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (const std::runtime_error &ex)
|
|
||||||
{
|
|
||||||
qDebug() << "Error parsing moderation action:" << ex.what();
|
|
||||||
}
|
|
||||||
|
|
||||||
action.modded = true;
|
action.modded = true;
|
||||||
|
|
||||||
|
QString innerType;
|
||||||
|
if (rj::getSafe(data, "type", innerType) &&
|
||||||
|
innerType == "chat_login_moderation")
|
||||||
|
{
|
||||||
|
// Don't display the old message type
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!getTargetUser(data, action.target))
|
||||||
|
{
|
||||||
|
qDebug() << "Error parsing moderation action mod: Unable to get "
|
||||||
|
"target_user_id";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load target name from message.data.target_user_login
|
||||||
|
if (!getTargetUserName(data, action.target))
|
||||||
|
{
|
||||||
|
qDebug() << "Error parsing moderation action mod: Unable to get "
|
||||||
|
"target_user_name";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->signals_.moderation.moderationStateChanged.invoke(action);
|
this->signals_.moderation.moderationStateChanged.invoke(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user)
|
||||||
return rj::getSafe(data, "target_user_id", user.id);
|
return rj::getSafe(data, "target_user_id", user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getTargetUserName(const rapidjson::Value &data, ActionUser &user)
|
||||||
|
{
|
||||||
|
return rj::getSafe(data, "target_user_login", user.name);
|
||||||
|
}
|
||||||
|
|
||||||
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
|
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
|
||||||
std::shared_ptr<TwitchAccount> account)
|
std::shared_ptr<TwitchAccount> account)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ const rapidjson::Value &getMsgID(const rapidjson::Value &data);
|
||||||
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
|
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
|
||||||
|
|
||||||
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
|
bool getTargetUser(const rapidjson::Value &data, ActionUser &user);
|
||||||
|
bool getTargetUserName(const rapidjson::Value &data, ActionUser &user);
|
||||||
|
|
||||||
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
|
rapidjson::Document createListenMessage(const std::vector<QString> &topicsVec,
|
||||||
std::shared_ptr<TwitchAccount> account);
|
std::shared_ptr<TwitchAccount> account);
|
||||||
|
|
Loading…
Reference in a new issue