Migrated Kraken's getUser to Helix (#2260)

This commit is contained in:
Paweł
2020-12-06 19:41:52 +01:00
committed by GitHub
parent 277ef4b2e3
commit cfa9e5903e
6 changed files with 9 additions and 61 deletions
+2
View File
@@ -22,6 +22,7 @@ struct HelixUser {
QString id;
QString login;
QString displayName;
QString createdAt;
QString description;
QString profileImageUrl;
int viewCount;
@@ -30,6 +31,7 @@ struct HelixUser {
: id(jsonObject.value("id").toString())
, login(jsonObject.value("login").toString())
, displayName(jsonObject.value("display_name").toString())
, createdAt(jsonObject.value("created_at").toString())
, description(jsonObject.value("description").toString())
, profileImageUrl(jsonObject.value("profile_image_url").toString())
, viewCount(jsonObject.value("view_count").toInt())
-20
View File
@@ -29,26 +29,6 @@ void Kraken::getChannel(QString userId,
.execute();
}
void Kraken::getUser(QString userId, ResultCallback<KrakenUser> successCallback,
KrakenFailureCallback failureCallback)
{
assert(!userId.isEmpty());
this->makeRequest("users/" + userId, {})
.onSuccess([successCallback, failureCallback](auto result) -> Outcome {
auto root = result.parseJson();
successCallback(root);
return Success;
})
.onError([failureCallback](auto result) {
// TODO: make better xd
failureCallback();
})
.execute();
}
NetworkRequest Kraken::makeRequest(QString url, QUrlQuery urlQuery)
{
assert(!url.startsWith("/"));
-15
View File
@@ -23,17 +23,6 @@ struct KrakenChannel {
}
};
struct KrakenUser {
const QString createdAt;
const QString displayName;
KrakenUser(QJsonObject jsonObject)
: createdAt(jsonObject.value("created_at").toString())
, displayName(jsonObject.value("display_name").toString())
{
}
};
class Kraken final : boost::noncopyable
{
public:
@@ -42,10 +31,6 @@ public:
ResultCallback<KrakenChannel> resultCallback,
KrakenFailureCallback failureCallback);
// https://dev.twitch.tv/docs/v5/reference/users#get-user-by-id
void getUser(QString userId, ResultCallback<KrakenUser> resultCallback,
KrakenFailureCallback failureCallback);
void update(QString clientId, QString oauthToken);
static void initialize();
+1 -10
View File
@@ -4,15 +4,6 @@ this folder describes what sort of API requests we do, what permissions are requ
## Kraken (V5)
We use a bunch of Kraken (V5) in Chatterino2.
### Get User
URL: https://dev.twitch.tv/docs/v5/reference/users#get-user-by-id
Migration path: **Unknown**
* We implement this in `providers/twitch/api/Kraken.cpp getUser`
Used in:
* `UserInfoPopup` to get the "created at" date of a user
### Get Channel
URL: https://dev.twitch.tv/docs/v5/reference/channels#get-channel
@@ -95,7 +86,7 @@ URL: https://dev.twitch.tv/docs/api/reference#get-users
* We implement this in `providers/twitch/api/Helix.cpp fetchUsers`.
Used in:
* `UserInfoPopup` to get ID and viewcount of username we clicked
* `UserInfoPopup` to get ID, viewCount, displayName, createdAt of username we clicked
* `CommandController` to power any commands that need to get a user ID
* `Toasts` to get the profile picture of a streamer who just went live
* `TwitchAccount` ignore and unignore features to translate user name to user ID