Migrated follow and unfollow methods to Helix API (#2306)
This commit is contained in:
@@ -315,6 +315,50 @@ void Helix::getGameById(QString gameId,
|
||||
failureCallback);
|
||||
}
|
||||
|
||||
void Helix::followUser(QString userId, QString targetId,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
QUrlQuery urlQuery;
|
||||
|
||||
urlQuery.addQueryItem("from_id", userId);
|
||||
urlQuery.addQueryItem("to_id", targetId);
|
||||
|
||||
this->makeRequest("users/follows", urlQuery)
|
||||
.type(NetworkRequestType::Post)
|
||||
.onSuccess([successCallback](auto result) -> Outcome {
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
// TODO: make better xd
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
void Helix::unfollowUser(QString userId, QString targetId,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback)
|
||||
{
|
||||
QUrlQuery urlQuery;
|
||||
|
||||
urlQuery.addQueryItem("from_id", userId);
|
||||
urlQuery.addQueryItem("to_id", targetId);
|
||||
|
||||
this->makeRequest("users/follows", urlQuery)
|
||||
.type(NetworkRequestType::Delete)
|
||||
.onSuccess([successCallback](auto result) -> Outcome {
|
||||
successCallback();
|
||||
return Success;
|
||||
})
|
||||
.onError([failureCallback](auto result) {
|
||||
// TODO: make better xd
|
||||
failureCallback();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
NetworkRequest Helix::makeRequest(QString url, QUrlQuery urlQuery)
|
||||
{
|
||||
assert(!url.startsWith("/"));
|
||||
|
||||
@@ -184,6 +184,14 @@ public:
|
||||
void getGameById(QString gameId, ResultCallback<HelixGame> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
void followUser(QString userId, QString targetId,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
void unfollowUser(QString userId, QString targetlId,
|
||||
std::function<void()> successCallback,
|
||||
HelixFailureCallback failureCallback);
|
||||
|
||||
void update(QString clientId, QString oauthToken);
|
||||
|
||||
static void initialize();
|
||||
|
||||
@@ -13,23 +13,6 @@ Migration path: **Unknown**
|
||||
Used in:
|
||||
* `TwitchChannel::refreshTitle` to check the current stream title/game of offline channels
|
||||
|
||||
### Follow Channel
|
||||
URL: https://dev.twitch.tv/docs/v5/reference/users#follow-channel
|
||||
Requires `user_follows_edit` scope
|
||||
|
||||
Migration path: **Unknown**
|
||||
|
||||
* We implement this API in `providers/twitch/TwitchAccount.cpp followUser`
|
||||
|
||||
### Unfollow Channel
|
||||
URL: https://dev.twitch.tv/docs/v5/reference/users#unfollow-channel
|
||||
Requires `user_follows_edit` scope
|
||||
|
||||
Migration path: **Unknown**
|
||||
|
||||
* We implement this API in `providers/twitch/TwitchAccount.cpp unfollowUser`
|
||||
|
||||
|
||||
### Get Cheermotes
|
||||
URL: https://dev.twitch.tv/docs/v5/reference/bits#get-cheermotes
|
||||
|
||||
@@ -106,6 +89,24 @@ URL: https://dev.twitch.tv/docs/api/reference#get-streams
|
||||
* `TwitchChannel` to get live status, game, title, and viewer count of a channel
|
||||
* `NotificationController` to provide notifications for channels you might not have open in Chatterino, but are still interested in getting notifications for
|
||||
|
||||
### Follow User
|
||||
URL: https://dev.twitch.tv/docs/api/reference#create-user-follows
|
||||
Requires `user:edit:follows` scope
|
||||
|
||||
* We implement this in `providers/twitch/api/Helix.cpp followUser`
|
||||
Used in:
|
||||
* `widgets/dialogs/UserInfoPopup.cpp` to follow a user by ticking follow checkbox in usercard
|
||||
* `controllers/commands/CommandController.cpp` in /follow command
|
||||
|
||||
### Unfollow User
|
||||
URL: https://dev.twitch.tv/docs/api/reference#delete-user-follows
|
||||
Requires `user:edit:follows` scope
|
||||
|
||||
* We implement this in `providers/twitch/api/Helix.cpp unfollowUser`
|
||||
Used in:
|
||||
* `widgets/dialogs/UserInfoPopup.cpp` to unfollow a user by unticking follow checkbox in usercard
|
||||
* `controllers/commands/CommandController.cpp` in /unfollow command
|
||||
|
||||
## TMI
|
||||
The TMI api is undocumented.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user