Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Goal
Adapt the cooldown timer enablement to the latest bug fix on the backend:
The
'slow-mode'own capability was replaced by'skip-slow-mode'. This capability should only be used to determine if the user can skip cooldown mode and not to determine if the channel has cooldown enabled. Thechannel.own_capabilitiesarray will contain capability'skip-slow-mode'if a user is assigned a role that hasskip-channel-cooldownpermission.🛠 Implementation details
Cooldown mode enablement is signaled by the presence of
channel.cooldownvalue (num of seconds).When cooldown mode is enabled a user can send a message only if:
channel.own_capabilitiesincludes'skip-slow-mode'channel.cooldownOtherwise the user has to wait until the cooldown period has elapsed before sending next message.
Updating cooldown state
✅ If the cooldown is enabled during active user connection (
channel.updatedevent containschannel.cooldownvalue), then the remaining cooldown time has to be recalculated based on the above criteria.✅ If the cooldown period is updated (
channel.updatedevent contains newchannel.cooldownvalue), then the remaining cooldown time has to be recalculated based on the above criteria.✅ If the cooldown is disabled (
channel.updatedevent does not containchannel.cooldownvalue), then the remaining cooldown time has to be set to 0 immediately, thus enabling sending messages.Known limitations
❌ Cooldown is not updated over WS if
skip-channel-cooldownperm is assigned to a role in dashboard. Channel data has to be queried anew to reflect that change.❌ Cooldown is not updated over WS if
skip-channel-cooldownperm is removed from a role in dashboard. Channel data has to be queried anew to reflect that change.