Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Twitch badges to Helix #4537

Merged
merged 38 commits into from
Apr 16, 2023

Conversation

ZonianMidian
Copy link
Contributor

@ZonianMidian ZonianMidian commented Apr 11, 2023

Pull request checklist:

Closes #4492

  • CHANGELOG.md was updated, if applicable

Description

The legacy badges endpoint will be closed for the first time on May 4 and permanently on June 1, so it is necessary to migrate this endpoint to the Helix API.
Official announcement: https://discuss.dev.twitch.tv/t/legacy-badges-endpoint-shutdown-details-and-timeline-june-2023/44621

@iProdigy
Copy link
Contributor

Did you forget to commit HelixGlobalBadges/HelixChannelBadges ?

@ZonianMidian
Copy link
Contributor Author

Did you forget to commit HelixGlobalBadges/HelixChannelBadges ?

That's right, I hadn't done it yet. Recently added in b997784

image

Copy link
Contributor

@iProdigy iProdigy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can remove Content-Type header as there is no request body

src/providers/twitch/api/Helix.cpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Outdated Show resolved Hide resolved
@iProdigy
Copy link
Contributor

Be sure to define virtual functions in IHelix for getGlobalBadges/getChannelBadges

@ZonianMidian
Copy link
Contributor Author

Be sure to define virtual functions in IHelix for getGlobalBadges/getChannelBadges

That's right, I was missing the definition of virtual variables in IHelix. Recently added in cd0c55d

@Felanbird
Copy link
Collaborator

Checking this PR from the artifact loads all badges as expected

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far!
The two remaining steps I see are:

  1. Modify the TwitchBadges.cpp function loadTwitchBadges to instead use the method you created getGlobalBadges()
  2. Modify the TwitchChannel.cpp function refreshBadges to instead use the method you created getChannelBadges(broadcasterID)

After that's done, the PR is ready for testing! 🧇

@dnsge
Copy link
Contributor

dnsge commented Apr 15, 2023

https://twitter.com/TwitchDev/status/1647017279123513344

Looks like the endpoint has been updated with some more info, not sure if anything in this PR needs to change. Perhaps the new info should parsed into our badge structs? Unclear if we would even use it.

@ZonianMidian
Copy link
Contributor Author

Looks like the endpoint has been updated with some more info, not sure if anything in this PR needs to change. Perhaps the new info should parsed into our badge structs? Unclear if we would even use it.

I believe that at the time of starting this PR those data were already available since they were released together with the official announcement. I guess it was only now that it was made public on Twitter 🤔

@Felanbird
Copy link
Collaborator

I believe that at the time of starting this PR those data were already available since they were released together with the official announcement. I guess it was only now that it was made public on Twitter 🤔

This is correct, @iProdigy confirmed all the data available from the legacy endpoint was also available in the Helix response the day after the deprecation announcement.

}
break;
}
qCWarning(chatterinoTwitch) << errorMessage;
QFile file(":/twitch-badges.json");
Copy link
Contributor

@iProdigy iProdigy Apr 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a follow-up PR, we can convert twitch-badges.json to use the new helix structure (this would allow enable a refactor of parseTwitchBadges that leverages the new structs from this PR).

ZonianMidian and others added 17 commits April 15, 2023 20:55
This prevents the parameter from being copied for each invocation -
since we know the lifetime of the object this is not a problem
There's not really a big gain in any particular way, but it makes it,
    imo, more readable since it's less code
We don't use the default constructor, so we don't need it defined
Bonus: This also adds a newline between the member variables & the
constructor
The Helix API calls it data,
but for us it makes more sense to call it `badgeSets`
also include identifiers in the message itself to make it more
identifiable
get is already the default request type if one is not specified (see NetworkRequest.hpp)
This is done by capturing a weak pointer of the channel into the success
& failure lambdas, then verifying that we're able to lock them when the
request has finished
Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! As a first-time contributor, you can now add yourself to the contributors list that's shown inside the About page in Chatterino.

If you want this, you can open a new PR where you modify the resources/contributors.txt file and add yourself to the list. Make sure to read the comments at the top for instructions.

@pajlada pajlada enabled auto-merge (squash) April 16, 2023 09:23
@pajlada pajlada merged commit d6ef48d into Chatterino:master Apr 16, 2023
@Felanbird Felanbird mentioned this pull request Apr 16, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Twitch badges to Helix
5 participants