diff options
| author | 2020-04-07 20:06:00 +0200 | |
|---|---|---|
| committer | 2020-04-07 20:06:00 +0200 | |
| commit | 8ca0b7f5161f0a71df39a36758b3d8041c895fe8 (patch) | |
| tree | ddd153ed525f3fda97bfedc3106f2194900dfcdd /tests/test_base.py | |
| parent | Change help available embed to use occupied term (diff) | |
Ensure available help channels sync their permissions
The help channels in the `Help: Available` category should automatically synchronize their permissions with the category permissions to ensure that the overwrites we use to prevent people from claiming multiple help channels are properly enforced. Unfortunately, for unknown reasons, they sometimes get in an "out of sync" state that requires intervention to get them back in sync.
This PR mitigates that issue by checking the available channel for their synchronisation status during certain critical times in our help channel system:
1. Whenever the overwrites for the category change
2. Whenever a channel is moved into the new category
3. After the categories have been reset during the initialization process
The check is straightforward: The `ensure_permissions_synchronization` method iterates over all the channels in the category and checks if the channels are currently synchronizing their permissions. If not, we remedy that by making a channel edit request to the Discord API. If all channels were already "in sync", no API calls are made. The latter should make this an inexpensive mitigation procedure: As we typically have very few channels in the available category and channels mostly stay in sync, we typically do very little.
To make this process a bit easier, I've factored out `set_permissions` calls to a helper function that also calls the `ensure_permissions_synchronization` method. The only exception is during the reset process: As we may edit multiple permissions in this loop, it's better to only ensure the synchronization after we're done with all permission changes.
Diffstat (limited to 'tests/test_base.py')
0 files changed, 0 insertions, 0 deletions