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

Rework permission checks #286

Closed

Conversation

jamesbt365
Copy link
Member

This shouldn't be breaking in the traditional sense, but does theoretically change behaviour in one case.

Previously, when the bots permissions could not be checked, it let the command run, now it fires a UserPermissionsError, there isn't really a nice way of checking where the error came from because the only place this can happen is in http requests.

The guild, channel or member itself could be the failure point, the only place we can now tell is directly on which member failed to fetch and return the "right" error from there.

I've placed a comment in the code about it, I just want to check if this is okay or if I should attempt to get the right error even though the only place it can come from is http.

I can pull the member from the cache too if that is desirable, but developers without GUILD_MEMBERS may suffer from this change. I believe checking for this is doable by directly accessing Http, but this is currently out of scope and can be handled later if that is desirable.

In serenity-next the channel http request has already been removed and I'd rather not mess around doing that bit manually and falling back to http if it isn't cached.

CURRENTLY UNTESTED.

@jamesbt365 jamesbt365 changed the title Reworked permission checks Rework permission checks Jul 15, 2024
@GnomedDev
Copy link
Member

Okay, currently this code is a mess because of cache and no cache support, and I see you adding the signature Option<(Option<_>, Option<_>)> which is sus to start with.

Can you abstract the distinct operations that need difference between cache and http into functions in a different file that we can switch between?

@jamesbt365
Copy link
Member Author

Lets go from where the most recent commit is, what else ideally should be done to make this more presentable and maintainable?

Copy link
Member

@GnomedDev GnomedDev left a comment

Choose a reason for hiding this comment

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

Okay, this looks a bit better (may just be me getting some sleep). Just a few improvements that will make this even better, and some testing needs to be done if not already.

src/dispatch/common.rs Outdated Show resolved Hide resolved
src/dispatch/common.rs Outdated Show resolved Hide resolved
src/dispatch/common.rs Outdated Show resolved Hide resolved
@jamesbt365 jamesbt365 force-pushed the reworked-permission-checks branch from 3c79dbc to fb0e42d Compare October 22, 2024 13:33
@jamesbt365 jamesbt365 changed the base branch from current to next October 22, 2024 15:10
@jamesbt365 jamesbt365 requested a review from GnomedDev November 5, 2024 15:22
@jamesbt365 jamesbt365 force-pushed the reworked-permission-checks branch 2 times, most recently from 4e1af94 to a58868b Compare November 13, 2024 14:14
@jamesbt365 jamesbt365 force-pushed the reworked-permission-checks branch from b49f06f to 6fe6a0a Compare November 13, 2024 14:21
@GnomedDev GnomedDev force-pushed the reworked-permission-checks branch from 91e9613 to 054f9ed Compare November 13, 2024 18:36
@GnomedDev
Copy link
Member

Closing in favor of #325.

@GnomedDev GnomedDev closed this Nov 13, 2024
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.

2 participants