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 /mods command to helix API #4103

Merged
merged 17 commits into from Nov 5, 2022
Merged

Conversation

cbclemmer
Copy link
Contributor

@cbclemmer cbclemmer commented Nov 3, 2022

Pull request checklist:

closes #3971

  • CHANGELOG.md was updated, if applicable

Description

Modeled after the /chatters migration PR #4088.

/mods command no longer uses the irc command and now makes a helix api request.
mod list is paginated just like chatter list.

@cbclemmer
Copy link
Contributor Author

@pajlada I tried to follow the same paradigm as your changes to the /chatters api request.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

src/controllers/commands/CommandController.cpp Outdated Show resolved Hide resolved
src/controllers/commands/CommandController.cpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Show resolved Hide resolved
src/providers/twitch/api/Helix.cpp Outdated Show resolved Hide resolved
@Felanbird
Copy link
Collaborator

This PR can get helixTimegate applied to it, as we know approximately what day the previous command will be deprecated.

The related code to copy can be found in the /vips PR https://github.com/Chatterino/chatterino2/pull/4053/files

@cbclemmer
Copy link
Contributor Author

@Felanbird I added the timegate logic.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Copy link
Collaborator

@Felanbird Felanbird left a comment

Choose a reason for hiding this comment

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

A few things I noticed:

    // /vips
    // The extra parenthesis around the failure callback is because its type contains a comma
    MOCK_METHOD(
        void, getChannelVIPs,
        (QString broadcasterID,
         ResultCallback<std::vector<HelixVip>> successCallback,
         (FailureCallback<HelixListVIPsError, QString> failureCallback)),
        (override));  // /vips

src/controllers/commands/CommandController.cpp Outdated Show resolved Hide resolved
src/controllers/commands/CommandController.cpp Outdated Show resolved Hide resolved
@Felanbird Felanbird linked an issue Nov 4, 2022 that may be closed by this pull request
@cbclemmer
Copy link
Contributor Author

@Felanbird All items from your previous comment should be fixed.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

tests/src/HighlightController.cpp Show resolved Hide resolved
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com>
Copy link
Collaborator

@Felanbird Felanbird left a comment

Choose a reason for hiding this comment

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

Functionality works 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.

Small change requests - last PR before Helix migration is done
image

src/singletons/Settings.hpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.hpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.hpp Outdated Show resolved Hide resolved
src/providers/twitch/api/Helix.hpp Show resolved Hide resolved
@pajlada
Copy link
Member

pajlada commented Nov 5, 2022

I tried to follow the same paradigm as your changes to the /chatters api request.

You followed the paradigm really well, and it turns out my implementation actually didn't work! I made it work now for sure, and I'll make a PR later to fix the Chatters command too

@pajlada pajlada enabled auto-merge (squash) November 5, 2022 11:01
@pajlada pajlada merged commit e531161 into Chatterino:master Nov 5, 2022
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -1657,6 +1657,62 @@ void TwitchMessageBuilder::listOfUsersSystemMessage(QString prefix,
}
}

void TwitchMessageBuilder::listOfUsersSystemMessage(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'listOfUsersSystemMessage' can be made static [readability-convert-member-functions-to-static]

Suggested change
void TwitchMessageBuilder::listOfUsersSystemMessage(
}static

@@ -1657,6 +1657,62 @@
}
}

void TwitchMessageBuilder::listOfUsersSystemMessage(
QString prefix, const std::vector<HelixModerator> &users, Channel *channel,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: the parameter 'prefix' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
QString prefix, const std::vector<HelixModerator> &users, Channel *channel,
sage(const &

@@ -1657,6 +1657,62 @@
}
}

void TwitchMessageBuilder::listOfUsersSystemMessage(
QString prefix, const std::vector<HelixModerator> &users, Channel *channel,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'users' is unused [misc-unused-parameters]

Suggested change
QString prefix, const std::vector<HelixModerator> &users, Channel *channel,
sage( /*users*/


using namespace chatterino;

static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'NUM_MODERATORS_TO_FETCH_PER_REQUEST' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

Suggested change
static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;
constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;

@@ -1859,6 +1867,115 @@
.execute();
}

void Helix::onFetchModeratorsSuccess(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'onFetchModeratorsSuccess' can be made static [readability-convert-member-functions-to-static]

Suggested change
void Helix::onFetchModeratorsSuccess(
static void Helix::onFetchModeratorsSuccess(


// https://dev.twitch.tv/docs/api/reference#get-moderators
void Helix::fetchModerators(
QString broadcasterID, int first, QString after,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: the parameter 'broadcasterID' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
QString broadcasterID, int first, QString after,
const QString& broadcasterID, int first, QString after,


// https://dev.twitch.tv/docs/api/reference#get-moderators
void Helix::fetchModerators(
QString broadcasterID, int first, QString after,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: the parameter 'after' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
QString broadcasterID, int first, QString after,
QString broadcasterID, int first, const QString& after,

case 401: {
if (message.startsWith("Missing scope",
Qt::CaseInsensitive))
{
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: repeated branch in conditional chain [bugprone-branch-clone]

                    {
                    ^

src/providers/twitch/api/Helix.cpp:1949: end of the original

                    }
                     ^

src/providers/twitch/api/Helix.cpp:1951: clone 1 starts here

                    {
                    ^

src/providers/twitch/api/Helix.cpp:1955: clone 2 starts here

                    {
                    ^

@@ -2106,6 +2223,25 @@
fetchSuccess(fetchSuccess), failureCallback);
}

// https://dev.twitch.tv/docs/api/reference#get-moderators
void Helix::getModerators(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'getModerators' can be made static [readability-convert-member-functions-to-static]

Suggested change
void Helix::getModerators(
static void Helix::getModerators(

@@ -2106,6 +2223,25 @@
fetchSuccess(fetchSuccess), failureCallback);
}

// https://dev.twitch.tv/docs/api/reference#get-moderators
void Helix::getModerators(
QString broadcasterID, int maxModeratorsToFetch,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: the parameter 'broadcasterID' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]

Suggested change
QString broadcasterID, int maxModeratorsToFetch,
const QString& broadcasterID, int maxModeratorsToFetch,

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 /mods command to Helix API
4 participants