Repository navigation
fix: add temp email rate limit - #2879
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a temporary organisation-scoped rate limit for recipient email sending as an abuse-prevention measure.
Changes:
- Adds 5-minute and 1-day recipient email rate limit definitions.
- Extends
getEmailContextto returnorganisationId. - Applies the new org email send check to signing email jobs and document resend flows.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/lib/server-only/rate-limit/rate-limits.ts |
Defines temporary recipient email send rate limiters. |
packages/lib/server-only/email/get-email-context.ts |
Adds organisation ID to email context responses. |
packages/lib/server-only/email/assert-org-email-send-allowed.ts |
Adds helper for checking org email send quota. |
packages/lib/server-only/document/resend-document.ts |
Applies rate limiting to manual document resend emails. |
packages/lib/jobs/definitions/emails/send-signing-email.handler.ts |
Applies rate limiting to signing email jobs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Remove this helper and all callers when the comprehensive abuse-prevention | ||
| * design lands. See .agents/plans/sharp-gold-wave-email-abuse-prevention.md | ||
| */ | ||
| export const assertOrgEmailSendAllowed = async (options: AssertOrgEmailSendAllowedOptions): Promise<Result> => { |
| const sendCheck = await assertOrgEmailSendAllowed({ organisationId }); | ||
|
|
||
| if (!sendCheck.allowed) { | ||
| throw new AppError(AppErrorCode.TOO_MANY_REQUESTS, { | ||
| message: 'Organisation email send rate limit exceeded', | ||
| userMessage: 'Email send rate limit reached. Please try again in a few minutes.', | ||
| }); |
| * Two layered windows: 100/5m and 1000/1d, both keyed to org id. Returns a | ||
| * result object so callers can choose to silently drop (job path) or throw | ||
| * (sync path). | ||
| * | ||
| * Remove this helper and all callers when the comprehensive abuse-prevention | ||
| * design lands. See .agents/plans/sharp-gold-wave-email-abuse-prevention.md |
Description
Add a temp rate limit for sending emails