-
Notifications
You must be signed in to change notification settings - Fork 32
feat: Verify Subscriber #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Verify Subscriber #112
Conversation
Abeeujah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job with your implementation 👍
| .merge(project::router()) | ||
| .merge(support_ticket::router()) | ||
| .merge(escrow::router()) | ||
| .merge(newsletter::router()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| Unsubscribed, | ||
| Bounced, | ||
| SpamComplaint, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good 👍
src/http/newsletter/domain.rs
Outdated
| pub subscribed_at: Option<chrono::DateTime<chrono::Utc>>, | ||
| pub created_at: chrono::DateTime<chrono::Utc>, | ||
| pub updated_at: Option<chrono::DateTime<chrono::Utc>>, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job with the domain modelling. 👍
| "/newsletter/verify", | ||
| post(verify_subscriber::verify_subscriber), | ||
| ) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| .await?; | ||
|
|
||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job with this implementation, the thought process, the modularization, everything, you did a great job 👍
| let res = app.request(req).await; | ||
|
|
||
| assert_eq!(res.status(), StatusCode::BAD_REQUEST); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Job with the tests, it's exhaustive and covers happy paths and known edge cases well 👍
|
@anonfedora Pls fix the conflict |
|
@anonfedora Pls your test is not passing. Make it to pass |
ONEONUORA
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation @anonfedora Keep up the good work
Newsletter Subscriber Verification Feature
🎯 Overview
Closes #105
This PR implements a newsletter subscriber verification system that allows subscribers to verify their subscription by providing a token sent to them during signup. This prevents spam and ensures only verified subscribers receive newsletters.
📋 Features
🚀 API Endpoint
Verify Subscriber
Request Body:
{ "token": "verification-token-123" }Success Response (200):
{ "message": "Subscriber successfully verified", "subscriber_id": "0198525e-16e4-7851-bd17-a2eab39641b9", "email": "user@example.com", "verified_at": "2025-07-28T18:49:14.730Z" }Error Responses:
400 Bad Request- Empty or invalid token format404 Not Found- Token not found or expired422 Unprocessable Entity- Subscriber already verified📁 Files Added/Modified
New Files
src/http/newsletter/mod.rs- Newsletter module routersrc/http/newsletter/domain.rs- Domain types and enumssrc/http/newsletter/verify_subscriber.rs- Verification endpointtests/api/newsletter.rs- Comprehensive test suiteModified Files
src/http/mod.rs- Added newsletter module to main routertests/api/main.rs- Added newsletter test module🗄️ Database Schema
The feature uses the existing newsletter schema:
🔍 Sample Queries
1. Create a New Subscriber
2. Verify Subscriber
3. Check Subscriber Status
4. Clean Up Expired Tokens
5. Newsletter Distribution Query
🧪 Test Coverage
Test Cases
Test Results
🔧 Implementation Details
Domain Types
Key Functions
verify_subscriber()- Main endpoint handlerfind_subscriber_by_token()- Database query with proper error handlingupdate_subscriber_status()- Atomic status update🛡️ Security Features
📈 Performance Considerations
subscription_tokentable✅ Checklist
Ready for review and merge! 🎉