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

feat: DiscordRoleFilter #68

Open
wants to merge 1 commit into
base: 5.0.x
Choose a base branch
from
Open

Conversation

troyburn
Copy link

@troyburn troyburn commented Jan 3, 2022

Implementation for new settings:
visible_roles
can_add_roles
can_remove_roles

Implementation for new settings:
 visible_roles
 can_add_roles
 can_remove_roles
@troyburn
Copy link
Author

troyburn commented Jan 3, 2022

Please find this pull request over some work I have done for my corporation that maybe of interest to others.
Specifically when the Discord server has many roles that are not the responsibility of SeAT to manage or modify.
Over this week I expect to finalize testing with our production SeAT system.

Thanks very much for the good work with this plugin.

Copy link
Owner

@warlof warlof 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 for that pull request.

there are interesting design choice - I wonder if the overall filter system shouldn't be moved upper in the stack though (seat-connector) leaving only setup fields tied to Discord .

what are your tests results ?

*
* @var string DEFAULT_CAN_REMOVE_ROLES
*/
public const DEFAULT_CAN_REMOVE_ROLES = '@@everyrole:RoleName Example2 RemoveMe';
Copy link
Owner

Choose a reason for hiding this comment

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

instead providing hardcoded roles list as value, wouldn't it be better to put this as field tooltip into connector settings ?

Copy link
Author

@troyburn troyburn Jan 30, 2022

Choose a reason for hiding this comment

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

IIRC the design goal is not to break peoples systems during an upgrade.

An empty value does not make the overall module (seat-discord-connector) work as most users might expect, the empty value will disable functionality.

Not sure tooltip information alone helps. I'm sure the tooltip information can be improved, I didn't spend much time on it (since I know what it does lol).

This is about a fresh install or an upgrade to this version and then opening the discord settings and ensuring the new fields are populated with defaults that continue to maintain old behavior where possible. In the case of this new feature that should be possible, hence this value is in code as well as documentation (README).

If you only put information in documentation and tooltips many people won't read/notice during upgrade and the first time they save the settings after upgrade (which could be months) their connector will stop working like it did before pressing Discord Settings -> Save. Because it will save an empty string value by default, which will change module behaviour.

How many support issues might this cause, due to not reading documentation around the uprade ?

The @@everyrole is an illegal role name on Discord, so was picked for its special meaning.
That role names in discord can contain spaces.
That the use of * it also a valid role name in discord.
Discord has a @everyone with special meaning, so it wasn't a far stretch to use @@everyrole

I'm trying to convey to someone not reading the seat-discord-connector documentation and making a guess how to configure seat-discord-connector with 2 or more roles and when roles contain spaces all at the same time. i.e. space is not the role name delimiter, space is allowed and considered part of the role name. So ideally the SeAT administrators best guess on what to do will be correct first time.


}

?>
Copy link
Owner

Choose a reason for hiding this comment

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

php closing tag is non longer expected

Copy link
Author

@troyburn troyburn Jan 30, 2022

Choose a reason for hiding this comment

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

habbit, PHP is my 15th language


}

?>
Copy link
Owner

Choose a reason for hiding this comment

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

php closing tag is non longer expected

Copy link
Author

@troyburn troyburn Jan 30, 2022

Choose a reason for hiding this comment

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

habbit, PHP is my 15th language

*/
public function __construct(string $spec = '', string $explodeOn = ':')
{
$this->filter_specs = explode($explodeOn, $spec);
Copy link
Owner

Choose a reason for hiding this comment

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

maybe collection could be useful here ?
https://laravel.com/docs/6.x/collections

Copy link
Author

Choose a reason for hiding this comment

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

does the configuration system allow storage and default conversion to collections ?
so the primary usage and input data types/format is directly from the string types in the settings dialogs
or does PHP now allow overloading of the constructor so an additional ctor can added

Copy link
Owner

Choose a reason for hiding this comment

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

collection will allow you to manipulate array of things, including way to exclude data from final result.
ie: https://laravel.com/docs/6.x/collections#method-filter

@troyburn
Copy link
Author

there are interesting design choice - I wonder if the overall filter system shouldn't be moved upper in the stack though (seat-connector) leaving only setup fields tied to Discord .

Maybe but I don't have experience there. We only use discord and it would require auditing all other connectors for conventions, then work validating it all. Not something I'm looking to do.

what are your tests results ?

Yes it went into production at the time of the PR and has resolved our role management issues. No further changes were needed.

I probably did remove some trailing ?> markers as I found unittests picked up a stray EOL and warned. But I think those ones were removed already and included in this PR.

The Codacy Static Code Analysis seems to be unhappy about *Test.php files added, I'm not fussed about fixing concerns in unittests.

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