From 7ce935dba78befaa7eb1b8462c45407f381e2bbb Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 25 Oct 2025 20:11:23 +0000 Subject: [PATCH] Fix free limits and email notifications for inactive users MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a user's subscription is inactive, they should be treated as a FREE plan user with all free tier limits applied and appropriate email notifications. Changes: - limit-service.ts: Use getActivePlan() for daily limit checks so inactive users get FREE plan daily limits (100/day) instead of unlimited - team-service.ts: Fix isPaidPlan flag in email notifications to check team.isActive, ensuring inactive users receive free plan messaging This ensures: 1. Inactive users have daily limits enforced (100 emails/day) 2. Inactive users receive correct email messaging (upgrade plan vs verify team) 3. All free tier limits apply when subscription is inactive 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/web/src/server/service/limit-service.ts | 5 +++-- apps/web/src/server/service/team-service.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/src/server/service/limit-service.ts b/apps/web/src/server/service/limit-service.ts index abaa1a94..c9c7462c 100644 --- a/apps/web/src/server/service/limit-service.ts +++ b/apps/web/src/server/service/limit-service.ts @@ -136,10 +136,11 @@ export class LimitService { ); const dailyUsage = usage.day.reduce((acc, curr) => acc + curr.sent, 0); + const activePlan = getActivePlan(team); const dailyLimit = - team.plan !== "FREE" + activePlan !== "FREE" ? team.dailyEmailLimit - : PLAN_LIMITS[team.plan].emailsPerDay; + : PLAN_LIMITS.FREE.emailsPerDay; logger.info( { dailyUsage, dailyLimit, team }, diff --git a/apps/web/src/server/service/team-service.ts b/apps/web/src/server/service/team-service.ts index 596ce514..64fb09de 100644 --- a/apps/web/src/server/service/team-service.ts +++ b/apps/web/src/server/service/team-service.ts @@ -400,7 +400,8 @@ export class TeamService { } const team = await TeamService.getTeamCached(teamId); - const isPaidPlan = team.plan !== "FREE"; + // Only consider it a paid plan if the subscription is active + const isPaidPlan = team.isActive && team.plan !== "FREE"; const html = await getLimitReachedEmail(teamId, limit, reason); @@ -501,7 +502,8 @@ export class TeamService { } const team = await TeamService.getTeamCached(teamId); - const isPaidPlan = team.plan !== "FREE"; + // Only consider it a paid plan if the subscription is active + const isPaidPlan = team.isActive && team.plan !== "FREE"; const period = reason === LimitReason.EMAIL_FREE_PLAN_MONTHLY_LIMIT_REACHED