Skip to content

Conversation

@CommitToday
Copy link

Fix for Issue #15541: Add Cooldown for Enchanted Armoire Purchases

Summary

This PR implements a cooldown mechanism to prevent users from making rapid, consecutive purchases from the Enchanted Armoire. A 2-second cooldown has been added to ensure that users must wait between purchases, addressing potential abuse or accidental rapid clicks.

Changes

  • Added new translation strings (armoirePurchaseTooFast) in both en and en_GB locales to inform users when they are clicking too rapidly.
  • Implemented a 2-second cooldown in the buyArmoire.js operation:
    • Checks the lastArmoirePurchase timestamp in the user's flags before allowing a new purchase.
    • Throws a NotAuthorized error with the new translation string if the cooldown period hasn't elapsed.
    • Updates the lastArmoirePurchase timestamp after a successful purchase.
  • Updated the user schema to include a lastArmoirePurchase field to track the last purchase time.

Technical Details

  • The cooldown is implemented server-side to prevent client-side bypass.
  • The lastArmoirePurchase field is stored in the user's flags object in the database.
  • The cooldown duration is set to 2 seconds to balance preventing spam with allowing reasonable usage.

Testing

  • Verify that the cooldown prevents multiple purchases within 2 seconds
  • Check that the error message is displayed appropriately
  • Ensure that purchases work normally after the cooldown period has elapsed
  • Confirm that the user schema change does not break existing functionality

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.

1 participant