Skip to content

Conversation

@MartinCupela
Copy link
Contributor

@MartinCupela MartinCupela commented May 25, 2023

🎯 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. The channel.own_capabilities array will contain capability 'skip-slow-mode' if a user is assigned a role that has skip-channel-cooldown permission.

🛠 Implementation details

Cooldown mode enablement is signaled by the presence of channel.cooldown value (num of seconds).

When cooldown mode is enabled a user can send a message only if:

  1. in the cooldown period if channel.own_capabilities includes 'skip-slow-mode'
  2. the time elapsed since the last message sent is > channel.cooldown
  3. no previous message was sent by the given user in the given channel

Otherwise 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.updated event contains channel.cooldown value), then the remaining cooldown time has to be recalculated based on the above criteria.
✅ If the cooldown period is updated (channel.updated event contains new channel.cooldown value), then the remaining cooldown time has to be recalculated based on the above criteria.
✅ If the cooldown is disabled (channel.updated event does not contain channel.cooldown value), 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-cooldown perm 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-cooldown perm is removed from a role in dashboard. Channel data has to be queried anew to reflect that change.

@MartinCupela MartinCupela changed the title Fix/cooldown timer fix: cooldown timer May 25, 2023
@MartinCupela MartinCupela merged commit 8f7c79f into develop Jun 27, 2023
@MartinCupela MartinCupela deleted the fix/cooldown-timer branch June 27, 2023 07:21
@MartinCupela MartinCupela mentioned this pull request Jun 27, 2023
github-actions bot pushed a commit that referenced this pull request Jun 27, 2023
## [10.8.5](v10.8.4...v10.8.5) (2023-06-27)

### Bug Fixes

* make cooldown timer to rely on skip-slow-mode capability  ([#2018](#2018)) ([8f7c79f](8f7c79f))
@github-actions
Copy link

🎉 This PR is included in version 10.8.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants