-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
feat(cache,http,model): guild timeouts #1342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The permission calculator in the util
crate should also be updated to reflect changes in permissions introduced by timeout:
Timed out members will temporarily lose all permissions except
VIEW_CHANNEL
andREAD_MESSAGE_HISTORY
. Owners and admin users withADMINISTRATOR
permissions are exempt.
That could be a bit problematic - that requires checking whether the member in question is timed out or not, which needs to take the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Permission calculator need to be updated as well, but I think it can be done in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, this isn't breaking. We should target this at main
.
Field is always present according to this discussion discord/discord-api-docs#4075 (comment) |
The base branch was changed.
Codecov Report
@@ Coverage Diff @@
## main #1342 +/- ##
=======================================
Coverage 32.92% 32.92%
=======================================
Files 366 366
Lines 14541 14541
=======================================
Hits 4788 4788
Misses 9753 9753 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that no events are sent when the timeout is over (discord/discord-api-docs#4269). Therefore, relying on whether communication_disabled_until
has a value does not allow knowing if a given member is actually timed out (especially when using cached data).
As checking if a member is timed out is a common use case, it should be highlighted that the presence of the field is not enough to know if a user is currently timed out. I suggest wrapping the Option<Timestamp>
in another type with specific methods for this use case.
Example implementation:
pub struct TimeoutState(Option<Timestamp>);
impl TimeoutState {
pub fn is_timed_out(&self) -> bool {
// Check if a member is currently timed out
}
pub fn until(&self) -> Option<&Timestamp> {
// Return the timestamp only if the user is currently timed out
}
pub fn inner(&self) -> Option<&Timestamp> {
// Return the raw (unchecked) timestamp value
}
}
A drawback is that the current time will be retrieved each time the is_timed_out
or until
method is called, but I think this could prevent some bugs. Anyway, the inner
method will allow getting the unchecked timestamp without performance drawback.
…for various cached member types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small things, looks good otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @7596ff, but I think that it should be highlighted in the CachedMember
documentation that the presence of the value is not enough to know if a member is timed out.
Does it make sense to highlight as such in |
As other |
Alright! |
Additions Support guild member timeouts via `Member::communication_disabled_until` and `Permissions::MODERATE_MEMBERS` ([#1342] - [@HTG-YT]). [@HTG-YT]: https://github.com/HTG-YT [#1342]: #1342 Signed-off-by: Zeyla Hellyer <[email protected]>
Additions Support guild member timeouts via `UpdateGuildMember::communication_disabled_until` ([#1342] - [@HTG-YT]). Support pre-flight cancelation to cancel requests after passing ratelimit queues but before sending ([#1353] - [@zeylahellyer]). Fixes Fix display implementation for Get Active Threads route ([#1386] - [@zeylahellyer]). Fix display implementation for Get Current User Application Info route ([#1389] - [@Erk-]). [@Erk-]: https://github.com/Erk- [@HTG-YT]: https://github.com/HTG-YT [@zeylahellyer]: https://github.com/zeylahellyer [#1389]: #1389 [#1386]: #1386 [#1353]: #1353 [#1342]: #1342 Signed-off-by: Zeyla Hellyer <[email protected]>
Additions Support guild member timeouts ([#1342] - [@HTG-YT]). Support iterating over a channel's list of cached messages via `InMemoryCache::channel_messages` ([#1362] - [@zeylahellyer]). [@HTG-YT]: https://github.com/HTG-YT [@zeylahellyer]: https://github.com/zeylahellyer [#1362]: #1362 [#1342]: #1342 Signed-off-by: Zeyla Hellyer <[email protected]>
Discord API PR (initial documentation): discord/discord-api-docs#4075
Discord API PR (further documentation): discord/discord-api-docs#4266