Fix subscription limits; seed Free/Good/Better/Best default plans
Agent-Logs-Url: https://github.com/christianlouis/pop_puller_to_gmail/sessions/98c1f90b-0287-4908-a0be-ad066c453cc5 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -25,10 +25,22 @@ async def list_subscription_plans(db: AsyncSession = Depends(get_db)):
|
||||
@router.get("/current")
|
||||
async def get_current_subscription(
|
||||
current_user: User = Depends(get_current_active_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
"""Get current user's subscription details"""
|
||||
"""Get current user's subscription details including plan limits"""
|
||||
plan_result = await db.execute(
|
||||
select(SubscriptionPlan).where(
|
||||
SubscriptionPlan.tier == current_user.subscription_tier,
|
||||
SubscriptionPlan.is_active.is_(True),
|
||||
)
|
||||
)
|
||||
plan = plan_result.scalar_one_or_none()
|
||||
|
||||
return {
|
||||
"tier": current_user.subscription_tier,
|
||||
"status": current_user.subscription_status,
|
||||
"expires_at": current_user.subscription_expires_at,
|
||||
"max_mail_accounts": plan.max_mail_accounts if plan else None,
|
||||
"max_emails_per_day": plan.max_emails_per_day if plan else None,
|
||||
"check_interval_minutes": plan.check_interval_minutes if plan else None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user