Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 7, 2025

  • Add comprehensive email notification system for support tickets
  • Implement user confirmation emails for bug reports and contact requests
  • Add support team notification emails for new tickets
  • Extend ticket status update email notifications
  • Improve error handling and logging for email sending processes
  • Utilize new support email utility functions for consistent communication
  • Add dynamic email generation based on ticket type and status Enhances user communication and provides better transparency in the support ticket lifecycle by implementing robust email notification mechanisms.

Summary by CodeRabbit

  • New Features
    • Automated confirmation emails now sent to users after submitting bug reports or support requests.
    • Support team receives notifications for newly created support tickets.
    • Users receive email notifications when their ticket status changes.

- Add comprehensive email notification system for support tickets
- Implement user confirmation emails for bug reports and contact requests
- Add support team notification emails for new tickets
- Extend ticket status update email notifications
- Improve error handling and logging for email sending processes
- Utilize new support email utility functions for consistent communication
- Add dynamic email generation based on ticket type and status
Enhances user communication and provides better transparency in the support ticket lifecycle by implementing robust email notification mechanisms.
@vercel
Copy link

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 7, 2025 5:53am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

A new email notification system is implemented for support tickets. User confirmation emails, support team notifications, and status update emails are now sent via dedicated utilities. These are integrated into bug report, contact form, and admin ticket status update endpoints.

Changes

Cohort / File(s) Summary
Email utilities
lib/email/support-emails.ts
New module with email template builders: getUserConfirmationEmail, getSupportTeamNotificationEmail, and getStatusUpdateEmail. Includes sendEmail function for dispatching via Resend service with RESEND_API_KEY validation and error logging.
Support ticket endpoints
app/api/support/bug-report/route.ts, app/api/support/contact/route.ts
Enhanced to fetch user profiles, capture inserted ticket data, and send user confirmation and support team notification emails after successful ticket creation. Support team email includes environment-based SUPPORT_EMAIL with fallback logging.
Admin ticket endpoint
app/api/admin/support/tickets/[id]/route.ts
Modified to fetch current ticket with user details before updating status, then send status change email to user only when status actually changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Client
    participant API as Endpoint<br/>(bug-report/contact)
    participant DB as Database
    participant Email as Email Service
    
    User->>Client: Submit form
    Client->>API: POST request
    
    rect rgba(200, 220, 255, 0.3)
    note over API,DB: Ticket Creation
    API->>DB: Fetch user profile
    API->>DB: Insert ticket, capture result
    DB-->>API: ticket data
    end
    
    rect rgba(220, 255, 220, 0.3)
    note over API,Email: Email Operations
    API->>Email: Send user confirmation email
    Email-->>API: success/error
    API->>Email: Send support team notification<br/>(if SUPPORT_EMAIL set)
    Email-->>API: success/error
    end
    
    API-->>Client: 200 OK + message
    Client-->>User: Confirmation displayed
Loading
sequenceDiagram
    participant Admin
    participant Client
    participant API as Admin Endpoint<br/>[id]/route.ts
    participant DB as Database
    participant Email as Email Service
    
    Admin->>Client: Update ticket status
    Client->>API: PATCH request
    
    rect rgba(200, 220, 255, 0.3)
    note over API,DB: Status Update
    API->>DB: Fetch current ticket + user
    DB-->>API: ticket, user data
    alt Ticket not found
        API-->>Client: 404
    else Status changed
        API->>DB: Update ticket status
        DB-->>API: updated ticket
    end
    end
    
    rect rgba(255, 240, 200, 0.3)
    note over API,Email: Conditional Email
    alt oldStatus ≠ newStatus<br/>AND user data exists
        API->>Email: Send status update email
        Email-->>API: success/error
    end
    end
    
    API-->>Client: 200 OK
    Client-->>Admin: Updated
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • lib/email/support-emails.ts: Verify HTML email template for security (injection risks), error handling with missing RESEND_API_KEY, and email body composition across different ticket types
  • Email integration across endpoints: Confirm consistent error handling when email sending fails, proper user profile fetching, and environment variable validation (SUPPORT_EMAIL, RESEND_API_KEY)
  • Conditional email logic: Review status change detection (oldStatus !== newStatus), user data availability checks, and edge cases where profile or user data may be missing
  • Type consistency: Validate ticket type enum values ('contact', 'bug') and parameter passing across email functions

Poem

🐰 A system for notes, now has wings to fly,
Emails bounce off servers way up high,
Confirmations sent, support teams notified,
Status updates shine—user-friendly pride!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/adminsupport

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df92bd8 and b7b5a59.

📒 Files selected for processing (4)
  • app/api/admin/support/tickets/[id]/route.ts (3 hunks)
  • app/api/support/bug-report/route.ts (3 hunks)
  • app/api/support/contact/route.ts (3 hunks)
  • lib/email/support-emails.ts (1 hunks)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeunia-dev codeunia-dev merged commit 4a5846f into main Nov 7, 2025
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants