Skip to content

fix: add temp email rate limit - #2879

Merged
dguyen merged 1 commit into
mainfrom
fix/rate-limit-emails
May 28, 2026
Merged

dguyen merged 1 commit into
mainfrom
fix/rate-limit-emails

Conversation

@dguyen

@dguyen dguyen commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Description

Add a temp rate limit for sending emails

Copilot AI review requested due to automatic review settings May 28, 2026 07:04
@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
prd-docs Ignored Ignored May 28, 2026 7:04am
prd-openpage-api Ignored Ignored May 28, 2026 7:04am
stg-docs Skipped Skipped May 28, 2026 7:04am

Request Review

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: d7bccfa1-f09c-4bc0-b241-144a948b02e6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/rate-limit-emails

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@roshboi roshboi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@dguyen
dguyen merged commit d304d87 into main May 28, 2026
10 of 11 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 getEmailContext to return organisationId.
  • 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> => {
Comment on lines +206 to +212
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.',
});
Comment on lines +16 to +21
* 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
@dguyen
dguyen deleted the fix/rate-limit-emails branch May 28, 2026 07:09
scoobs-mystery-bytes pushed a commit to scoobs-mystery-bytes/documenso that referenced this pull request May 30, 2026

This branch was previously deployed

1 inactive deployment
Preview – stg-docs — 95db01b2 Deployed May 28, 2026 by vercel[bot]
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.

4 participants