diff --git a/src/providers/twitch/PubsubClient.cpp b/src/providers/twitch/PubsubClient.cpp index c48d02c56..59526cb21 100644 --- a/src/providers/twitch/PubsubClient.cpp +++ b/src/providers/twitch/PubsubClient.cpp @@ -347,30 +347,31 @@ PubSub::PubSub() this->moderationActionHandlers["mod"] = [this](const auto &data, const auto &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; + 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); }; diff --git a/src/providers/twitch/PubsubHelpers.cpp b/src/providers/twitch/PubsubHelpers.cpp index d2e26ce13..f6f9b38e9 100644 --- a/src/providers/twitch/PubsubHelpers.cpp +++ b/src/providers/twitch/PubsubHelpers.cpp @@ -46,6 +46,11 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user) 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 &topicsVec, std::shared_ptr account) { diff --git a/src/providers/twitch/PubsubHelpers.hpp b/src/providers/twitch/PubsubHelpers.hpp index 3c784697a..d0854af26 100644 --- a/src/providers/twitch/PubsubHelpers.hpp +++ b/src/providers/twitch/PubsubHelpers.hpp @@ -16,6 +16,7 @@ const rapidjson::Value &getMsgID(const rapidjson::Value &data); bool getCreatedByUser(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 &topicsVec, std::shared_ptr account);