logs.gokuls.in

3 pull requests merged across 2 repos

bahdotsh/blogr

  • Add POST /newsletters/send endpoint to compose a custom newsletter from markdown content and send it to all approved subscribers (with optional tag filtering)
  • Add POST /newsletters/preview endpoint to compose and return rendered HTML/text preview without sending
  • Both endpoints are protected behind API key auth, validate inputs, and use the existing queue-based sender with rate limiting and crash recovery

Test plan

  • cargo test — all 103 tests pass
  • cargo clippy — no warnings
  • Verify POST /newsletters/preview returns composed HTML/text for valid subject + markdown content
  • Verify POST /newsletters/send composes and delivers to approved subscribers
  • Verify empty subject/content returns 400
  • Verify unauthenticated requests return 401
  • Verify optional tag field filters recipient list
  • Startup cleanup: Wire up existing but uncalled cleanup_expired_tokens(), cleanup_completed_send_queue(), and cleanup_old_send_recipients(90) on NewsletterManager initialization to prevent unbounded database growth
  • API rate limiting: Add sliding-window rate limiter middleware (configurable via ApiConfig.rate_limit) that returns 429 Too Many Requests when exceeded
  • Status transition fixes: Approving a subscriber now clears declined_at, declining clears approved_at — both in the database layer (update_subscriber_status_by_email) and the API layer (update_subscriber)
  • Email validation hardening: Add RFC 5321 character validation for local part and per-label domain validation (max 63 chars, no leading/trailing hyphens, alphanumeric + hyphen only)
  • Tag validation: New is_valid_tag() with MAX_TAG_LENGTH (100) and MAX_TAGS_PER_SUBSCRIBER (50) enforced at database (add_tag, set_tags) and API (update_subscriber_tags) layers
  • 10 new tests covering email validation edge cases, status transitions, and tag validation (89 total passing)

Test plan

  • cargo test -p blogr-cli — 89 tests pass
  • cargo clippy --all-targets --all-features -- -D warnings — clean
  • cargo fmt --all -- --check — clean

rust-lang/this-week-in-rust

Community Links