feat: POST /api/contact with Resend email and validation #19

Closed
pook wants to merge 23 commits from feature/api-contact-endpoint into main
Owner

Summary

  • Upgrades contact form endpoint from /contact to /api/contact with Resend email notifications replacing Twilio SMS
  • Adds field-level validation (422 responses): name/email required, message 10-2000 chars, optional phone with format check
  • Rate limiting tightened to 5 submissions per IP per hour
  • Requires RESEND_API_KEY and CONTACT_EMAIL environment variables

Test plan

  • All 33 tests pass (including 12 new/updated validation, rate limit, email send failure tests)
  • Lint check: no new ruff warnings introduced
  • Verify Resend email delivery in staging with real API key
  • Update DNS/SPF records for noreply@viztekpro.com if not already configured

Closes #10

🤖 Generated with Claude Code

## Summary - Upgrades contact form endpoint from `/contact` to `/api/contact` with Resend email notifications replacing Twilio SMS - Adds field-level validation (422 responses): name/email required, message 10-2000 chars, optional phone with format check - Rate limiting tightened to 5 submissions per IP per hour - Requires `RESEND_API_KEY` and `CONTACT_EMAIL` environment variables ## Test plan - [x] All 33 tests pass (including 12 new/updated validation, rate limit, email send failure tests) - [x] Lint check: no new ruff warnings introduced - [ ] Verify Resend email delivery in staging with real API key - [ ] Update DNS/SPF records for noreply@viztekpro.com if not already configured Closes #10 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat: add POST /api/contact with Resend email, field validation, rate limiting
Some checks failed
agent-worker/pr-tests Running PR tests...
CI / test (pull_request) Has been cancelled
CI / docker-build (pull_request) Has been cancelled
cf409b9928
Upgrade the contact form endpoint to meet issue #10 requirements:
- Route changed from /contact to /api/contact
- Field-level validation with 422 responses (name, email required; message 10-2000 chars; phone optional)
- Email notifications via Resend API replacing Twilio SMS
- Rate limiting: 5 submissions per IP per hour (was 5/minute)
- Requires RESEND_API_KEY and CONTACT_EMAIL environment variables
- Returns 500 with user-friendly message on email send failure

Closes #10

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

⚠️ No Test Suite Detected

Commit: cf409b99

No test script found in package.json. Add a test script to enable automated testing.

## ⚠️ No Test Suite Detected **Commit:** `cf409b99` No `test` script found in `package.json`. Add a test script to enable automated testing.
Author
Owner

PR #19 Build Verification Report

Date: 2026-04-11 | Branch: feature/api-contact-endpoint | Commit: cf409b9

1. Syntax Check

app.py: syntax OK

2. Test Suite (pytest)

33 passed, 4 warnings in 0.99s

All 33 tests pass including 12 new/updated validation, rate limit, and email tests.

Warnings (non-blocking): 4 deprecation warnings for on_event — FastAPI recommends migrating to lifespan event handlers.

3. Lint (ruff) — 7 issues found

app.py (3 errors):

  • F841 line 648: has_prior_assistant_response assigned but never used
  • F823 line 807: sms_failures referenced before assignment (missing global declaration)
  • F841 line 810: sms_failures assigned but never used (same scoping issue)

test_app.py (4 errors):

  • F401 line 7: hmac imported but unused
  • F401 line 11: threading imported but unused
  • F401 line 12: collections.defaultdict imported but unused
  • F401 line 13: time.monotonic imported but unused

4. Docker Build

Docker not available in verification environment — skipped.

Recommendation

All tests pass and the core logic is correct. The lint issues to address before merge:

  • Critical: The sms_failures scoping bug (F823 at line 807) needs a global sms_failures declaration in health_detail(), otherwise it will raise UnboundLocalError at runtime.
  • Minor: 4 unused imports in test_app.py (auto-fixable with ruff check --fix).
  • Minor: Unused variable has_prior_assistant_response on line 648.

Fix the sms_failures scoping bug and unused imports, then merge.


Automated verification by agent-bot — replaces stale issues #85, #83, #78, #51

## PR #19 Build Verification Report **Date:** 2026-04-11 | **Branch:** `feature/api-contact-endpoint` | **Commit:** `cf409b9` ### 1. Syntax Check ``` app.py: syntax OK ``` ### 2. Test Suite (pytest) ``` 33 passed, 4 warnings in 0.99s ``` All 33 tests pass including 12 new/updated validation, rate limit, and email tests. **Warnings (non-blocking):** 4 deprecation warnings for `on_event` — FastAPI recommends migrating to lifespan event handlers. ### 3. Lint (ruff) — 7 issues found **app.py (3 errors):** - `F841` line 648: `has_prior_assistant_response` assigned but never used - `F823` line 807: `sms_failures` referenced before assignment (missing `global` declaration) - `F841` line 810: `sms_failures` assigned but never used (same scoping issue) **test_app.py (4 errors):** - `F401` line 7: `hmac` imported but unused - `F401` line 11: `threading` imported but unused - `F401` line 12: `collections.defaultdict` imported but unused - `F401` line 13: `time.monotonic` imported but unused ### 4. Docker Build Docker not available in verification environment — skipped. ### Recommendation **All tests pass and the core logic is correct.** The lint issues to address before merge: - **Critical:** The `sms_failures` scoping bug (F823 at line 807) needs a `global sms_failures` declaration in `health_detail()`, otherwise it will raise `UnboundLocalError` at runtime. - **Minor:** 4 unused imports in test_app.py (auto-fixable with `ruff check --fix`). - **Minor:** Unused variable `has_prior_assistant_response` on line 648. **Fix the sms_failures scoping bug and unused imports, then merge.** --- _Automated verification by agent-bot — replaces stale issues #85, #83, #78, #51_
pook closed this pull request 2026-04-21 20:29:46 -04:00
Some checks failed
agent-worker/pr-tests Running PR tests...
CI / test (pull_request) Has been cancelled
CI / docker-build (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/vision-tech-solutions!19
No description provided.