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

[Starboard] Separate blocked/allowed roles and channels #528

Conversation

quachtridat
Copy link
Member

@quachtridat quachtridat commented Dec 29, 2021

Summary

This PR separates roles and channels in blacklist and whitelist by creating additional blacklists and whitelists for roles and channels, and lets the cog check if both the star-giver role and the channel are good before posting a starboard post. This should fix TrustyJAID/Trusty-cogs#261 and fix TrustyJAID/Trusty-cogs#269.

Details

Before this PR

When a post is starred, before posting to an appropriate starboard, the cog checks if either:

  • The person who starred the post has a permitted role, or
  • The channel containing the starred post is a permitted channel.

A permitted role is a Discord role, and, satisfies at least one of these conditions (in that order*):

  • Must be present in the whitelist if the whitelist contains any roles or channels. If the whitelist is empty,
  • Must be absent from the blacklist if the blacklist contains any roles or channels.

The same logic applies for checking whether a Discord (text/category) channel is a permitted channel.

After this PR

When a post is starred, before posting to an appropriate starboard, the cog checks if the person who starred the post has both a permitted role and the channel containing the starred post is a permitted channel.

A permitted role is a Discord role, and, satisfies all of these conditions (in that order*):

  • Must be absent from the role blacklist if the blacklist contains any roles.
  • Must be present in the role whitelist if the whitelist contains any roles.

The similar logic applies for checking whether a Discord (text/category) channel is a permitted channel. The only difference is that the channel blacklist/whitelist in which case contains only (zero or more) channels.

* The latter checks get evaluted only after the former checks have been evaluated.

Notes

This PR only adds additional blacklists and whitelists for roles and channels, and still lets the cog add/remove channels/roles to/from its existing whitelist and blacklist. Also, a large portion of the existing code is kept undeleted. We can clean things up when there is a fix for TrustyJAID/Trusty-cogs#261 and TrustyJAID/Trusty-cogs#269 from upstream (TrustyJAID/Trusty-cogs).

- Separate roles and channels in blacklist and whitelist.
- Let the cog check if BOTH the star-giver role AND the channel are good
before posting a starboard post.
@quachtridat quachtridat requested a review from a team December 29, 2021 04:01
@quachtridat quachtridat self-assigned this Dec 29, 2021
@quachtridat
Copy link
Member Author

Closing this because we have got an update from upstream that can resolve the problem.
TrustyJAID/Trusty-cogs@d463313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant