Move TwitchUser deserialization to the proper Deserialize function

instead of ::fromJSON
This commit is contained in:
Rasmus Karlsson
2018-06-27 00:17:05 +00:00
parent f76512c31e
commit e9868fdd84
3 changed files with 58 additions and 27 deletions
+13 -2
View File
@@ -106,7 +106,13 @@ void TwitchAccount::loadIgnores()
if (userIt == block.MemberEnd()) {
continue;
}
this->ignores.insert(TwitchUser::fromJSON(userIt->value));
TwitchUser ignoredUser;
if (!rj::getSafe(userIt->value, ignoredUser)) {
Log("Error parsing twitch user JSON {}", rj::stringify(userIt->value));
continue;
}
this->ignores.insert(ignoredUser);
}
}
@@ -155,7 +161,12 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe
return false;
}
auto ignoredUser = TwitchUser::fromJSON(userIt->value);
TwitchUser ignoredUser;
if (!rj::getSafe(userIt->value, ignoredUser)) {
onFinished(IgnoreResult_Failed,
"Bad JSON data while ignoring user (invalid user) " + targetName);
return false;
}
{
std::lock_guard<std::mutex> lock(this->ignoresMutex);