mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
bf0b5d08d8
Simplify authorized network requests for Twitch V5 api add onShow virtual function to settings pages if they need to be refreshed when shown Actually ignoring messages from ignored users is still not implemented Working on #247
35 lines
783 B
C++
35 lines
783 B
C++
#include "providers/twitch/twitchuser.hpp"
|
|
|
|
#include "util/rapidjson-helpers.hpp"
|
|
|
|
namespace chatterino {
|
|
namespace providers {
|
|
namespace twitch {
|
|
|
|
TwitchUser TwitchUser::fromJSON(const rapidjson::Value &value)
|
|
{
|
|
TwitchUser user;
|
|
|
|
if (!value.IsObject()) {
|
|
throw std::runtime_error("JSON value is not an object");
|
|
}
|
|
|
|
if (!rj::getSafe(value, "_id", user.id)) {
|
|
throw std::runtime_error("Missing ID key");
|
|
}
|
|
|
|
if (!rj::getSafe(value, "name", user.name)) {
|
|
throw std::runtime_error("Missing name key");
|
|
}
|
|
|
|
if (!rj::getSafe(value, "display_name", user.displayName)) {
|
|
throw std::runtime_error("Missing display name key");
|
|
}
|
|
|
|
return user;
|
|
}
|
|
|
|
} // namespace twitch
|
|
} // namespace providers
|
|
} // namespace chatterino
|