Added more functionality and clickable deny and accept buttons that don't do anything, this also fixes the issue with the background not working properly

This commit is contained in:
apa420
2019-01-20 14:45:59 +01:00
parent 0b2480d715
commit 7067b0503d
11 changed files with 64 additions and 14 deletions
+2
View File
@@ -113,6 +113,8 @@ struct AutomodAction : PubSubAction {
QString message;
QString reason;
QString msgID;
};
} // namespace chatterino
+8 -1
View File
@@ -532,6 +532,8 @@ PubSub::PubSub()
try
{
const auto &args = getArgs(data);
const auto &msgID = getMsgID(data);
// qDebug() << QString::fromStdString(rj::stringify(data));
if (args.Size() < 1)
{
@@ -559,6 +561,11 @@ PubSub::PubSub()
}
}
if (!rj::getSafe(msgID, action.msgID))
{
return;
}
this->signals_.moderation.automodMessage.invoke(action);
}
catch (const std::runtime_error &ex)
@@ -624,7 +631,7 @@ PubSub::PubSub()
// Add an initial client
this->addClient();
}
} // namespace chatterino
void PubSub::addClient()
{
+12
View File
@@ -23,6 +23,18 @@ const rapidjson::Value &getArgs(const rapidjson::Value &data)
return args;
}
const rapidjson::Value &getMsgID(const rapidjson::Value &data)
{
if (!data.HasMember("msg_id"))
{
throw std::runtime_error("Missing member msg_id");
}
const auto &msgID = data["msg_id"];
return msgID;
}
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user)
{
return rj::getSafe(data, "created_by", user.name) &&
+1
View File
@@ -12,6 +12,7 @@ class TwitchAccount;
struct ActionUser;
const rapidjson::Value &getArgs(const rapidjson::Value &data);
const rapidjson::Value &getMsgID(const rapidjson::Value &data);
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
+2
View File
@@ -413,6 +413,8 @@ AccessGuard<const TwitchAccount::TwitchAccountEmoteData>
return this->emotes_.accessConst();
}
// AutoModActions
void TwitchAccount::parseEmotes(const rapidjson::Document &root)
{
auto emoteData = this->emotes_.access();
+6
View File
@@ -108,6 +108,12 @@ public:
void loadEmotes();
AccessGuard<const TwitchAccountEmoteData> accessEmotes() const;
// Automod actions
void autoModAllow(const QString msgID,
std::function<void()> successCallback);
void autoModDeny(const QString msgID,
std::function<void()> successCallback);
private:
void parseEmotes(const rapidjson::Document &document);
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);