Skip to content

feat(mails): per-recipient rate limit on sendMail#124

Merged
albanm merged 8 commits into
masterfrom
chore-email-rate-limiting
May 26, 2026
Merged

feat(mails): per-recipient rate limit on sendMail#124
albanm merged 8 commits into
masterfrom
chore-email-rate-limiting

Conversation

@albanm
Copy link
Copy Markdown
Member

@albanm albanm commented May 26, 2026

Summary

Adds a per-recipient mail rate limit so a bug or runaway webhook can't spam a user's mailbox.

Changes

  • New mailLimiter factory in api/src/utils/limiter.ts (Mongo-backed, mirrors the existing auth limiter).
  • sendMail now splits the to field, consumes one point per recipient, drops over-limit addresses, and logs each drop via internalError('mail-rate-limited', …). If all recipients
    are dropped the mail is skipped entirely.
  • New config mailsRateLimit { points, duration } (defaults: 500 / 24h), exposed via env vars and JSON schema. Test overrides set very low values to make limits exercisable.
  • Reject sendMailI18n calls with non-http(s) link protocols.
  • Docs: per-recipient rate limit section added to docs/architecture/emails.md.

albanm and others added 8 commits May 26, 2026 10:27
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@albanm albanm merged commit 2ac394f into master May 26, 2026
4 checks passed
@albanm albanm deleted the chore-email-rate-limiting branch May 26, 2026 09:46
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.

1 participant