Develop#31
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (20)
WalkthroughThis PR implements three independent feature sets for ByteSend 0.3.2: end-to-end account ban enforcement (auth callbacks, JWT, middleware redirect, tRPC middleware, public REST API, and a new ChangesBan Enforcement
Email Deliverability: Bounce/Complaint Enforcement, RFC 8058 Unsubscribe, and Notification Routing
Admin Panel Enhancements
Sequence Diagram(s)sequenceDiagram
participant User
participant middleware as Next.js Middleware
participant authedProcedure as tRPC authedProcedure
participant getTeamFromToken as REST getTeamFromToken
participant db as Database
User->>middleware: Request to dashboard route
middleware->>middleware: Verify JWT token
middleware->>middleware: Check token.isBanned
alt isBanned = true
middleware-->>User: 302 redirect to /banned
else isBanned = false
middleware-->>User: Continue to route
User->>authedProcedure: tRPC mutation/query
authedProcedure->>db: SELECT isBanned FROM user WHERE id = session.user.id
db-->>authedProcedure: isBanned
alt isBanned = true
authedProcedure-->>User: FORBIDDEN (account suspended)
else isBanned = false
authedProcedure-->>User: Proceed to resolver
end
User->>getTeamFromToken: REST API request with API key
getTeamFromToken->>db: Find teamUser with role=ADMIN and user.isBanned=true
db-->>getTeamFromToken: banned admin found?
alt banned admin found
getTeamFromToken-->>User: FORBIDDEN (account suspended)
else no banned admin
getTeamFromToken-->>User: Return team data
end
end
sequenceDiagram
participant LimitService
participant db as dailyEmailUsage (DB)
participant Discord
participant NotificationProviderService
participant SESHookParser
LimitService->>LimitService: checkEmailLimit(teamId)
LimitService->>db: aggregate 7-day hardBounced/complained/delivered
db-->>LimitService: stats
alt delivered >= MIN_DELIVERED
LimitService->>LimitService: compute bounceRate, complaintRate
alt bounceRate >= HARD_LIMIT
LimitService->>Discord: sendToDiscord (bounce block alert)
LimitService-->>LimitService: return BOUNCE_RATE_EXCEEDED
else complaintRate >= HARD_LIMIT
LimitService->>Discord: sendToDiscord (complaint block alert)
LimitService-->>LimitService: return COMPLAINT_RATE_EXCEEDED
else rate >= WARN_LIMIT
LimitService->>Discord: sendToDiscord (reputation warning)
end
end
SESHookParser->>NotificationProviderService: broadcastNotification(teamId, EMAIL_BOUNCED/EMAIL_COMPLAINED)
NotificationProviderService->>NotificationProviderService: fan-out to team providers
NotificationProviderService->>Discord: admin observer webhook (ADMIN_DISCORD_WEBHOOK_URL)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Describe what changed and why.
Type of Change
Testing
List what you ran:
pnpm lintpnpm buildCommands/results:
Screenshots / Evidence (if applicable)
Add screenshots, recordings, or logs.
Checklist
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation