-
Notifications
You must be signed in to change notification settings - Fork 5
Add endpoint for creating scheduled newsletters #127
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
Conversation
…g and timezone handling
Deploying mxtoai-backend with
|
| Latest commit: |
40fdc5b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c5c84f25.mxtoai-backend.pages.dev |
| Branch Preview URL: | https://bk-news-endpoint.mxtoai-backend.pages.dev |
|
There's a merge conflict with main branch, let's resolve that as well |
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.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
d736062 to
3709034
Compare
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.
Pull request overview
Copilot reviewed 10 out of 11 changed files in this pull request and generated 9 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3f61c7f to
aae0c8e
Compare
Description
Closes #126
This PR introduces the
POST /create-newsletterendpoint, which allows authenticated users to schedule recurring newsletters. The implementation includes plan-based limits and sends a sample newsletter to whitelisted users upon creation.The
/userendpoint has also been updated to return newsletter usage stats.Checklist
Additional Notes
Changes by File
mxgo/api.py:/create-newsletterendpoint./userendpoint to includenewsletter_usagein the response.mxgo/config.py:NEWSLETTER_LIMITS_BY_PLANto define the limits.mxgo/schemas.py:CreateNewsletterRequestandCreateNewsletterResponsefor the new endpoint.ScheduleOptionsto accept a user-friendly schedule (e.g., weekly on specific days) instead of a raw cron string.mxgo/utils.py:convert_schedule_to_cron_listto convert the newScheduleOptionsinto one or more cron expressions.calculate_cron_intervalto validate schedule frequency against plan limits.tests/test_api.py:/create-newsletter.Request Response Structure
Request:
POST /create-newsletter{ "prompt": "Weekly summary of AI advancements", "schedule": { "type": "RECURRING_WEEKLY", "recurring_weekly": { "days": ["friday"], "time": "09:00" } } }Success Response (200 OK):
{ "is_scheduled": true, "is_whitelisted": true, "sample_email_sent": true, "scheduled_task_ids": [ "c4a6b2e8-6e7b-4a1d-8c3e-0f1d5e2a3b4c" ] }