Skip to content

Rate-limit emails sent by the same user in a period of time #9462

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

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

mtomilov
Copy link
Contributor

@mtomilov mtomilov commented Apr 9, 2025

Fixes #9411

Here we rate-limit emails sent by a single user to 100 within the last 24h to prevent abuse.

Testing

  • Set DAILY_SENDER_MENTION_LIMIT to a lower value like 5
  • Log in as devdata_admin
  • Create 6 annotations mentioning devdata_user
  • Observe that only 5 emails are present in the mail folder
  • Observe the limit reached line in celery logs

@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch 2 times, most recently from c5a2d3c to 5a0d099 Compare April 9, 2025 15:30
@mtomilov mtomilov marked this pull request as draft April 9, 2025 17:04
@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch from 5a0d099 to 0a23f35 Compare April 10, 2025 11:02
@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch from 0a23f35 to 615fce8 Compare April 10, 2025 11:13
@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch from 615fce8 to 14a98ad Compare April 10, 2025 11:18
@mtomilov mtomilov marked this pull request as ready for review April 10, 2025 11:26
@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch 2 times, most recently from c9f07f3 to d70c942 Compare April 10, 2025 13:47
@mtomilov mtomilov requested review from acelaya and seanh April 10, 2025 13:51
Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

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

Looks good!

I tested it by setting DAILY_SENDER_MENTION_LIMIT = 3. After the third mention, I was not able to send more, and the warning message was logged

@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch 3 times, most recently from 532c933 to a96397d Compare April 15, 2025 14:00
@mtomilov mtomilov force-pushed the rate-limit-emails-by-the-same-user branch from a96397d to 6e8a8ce Compare April 15, 2025 14:06
@mtomilov mtomilov merged commit a5f1dc6 into main Apr 15, 2025
11 checks passed
@mtomilov mtomilov deleted the rate-limit-emails-by-the-same-user branch April 15, 2025 14:11
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.

Rate-limit emails sent by the same user in a period of time
2 participants