Go to file
2025-05-06 18:24:32 +02:00
app missions api2 2025-05-06 16:35:05 +02:00
components missions s3 2025-05-06 12:46:06 +02:00
electron build fix 2025-05-05 17:09:36 +02:00
hooks courrier 2025-05-04 22:42:54 +02:00
lib missions api2 2025-05-06 18:24:32 +02:00
node_modules build fix 2025-05-05 13:16:37 +02:00
prisma missions page 2 2025-05-06 15:36:15 +02:00
public missions carrousse 2025-05-06 10:11:04 +02:00
redis Initial commit 2025-05-03 14:17:46 +02:00
scripts missions carrousse 2025-05-06 10:59:38 +02:00
styles Initial commit 2025-05-03 14:17:46 +02:00
types build fix 2025-05-05 17:09:36 +02:00
.DS_Store missions carrousse 2025-05-06 10:11:04 +02:00
.env missions api2 2025-05-06 17:14:37 +02:00
components.json Initial commit 2025-05-03 14:17:46 +02:00
db_query.sql Initial commit 2025-05-03 14:17:46 +02:00
DEPRECATED_FUNCTIONS.md dolibarr user 2025-05-04 10:15:48 +02:00
docker-compose.yml build fix 2025-05-05 12:20:41 +02:00
Dockerfile Initial commit 2025-05-03 14:17:46 +02:00
global.d.ts Initial commit 2025-05-03 14:17:46 +02:00
keycloak-user-creation-workflow.json Initial commit 2025-05-03 14:17:46 +02:00
next-env.d.ts Initial commit 2025-05-03 14:17:46 +02:00
next.config.js Initial commit 2025-05-03 14:17:46 +02:00
next.config.mjs Initial commit 2025-05-03 14:17:46 +02:00
package-lock.json courrier 2025-05-04 22:14:41 +02:00
package.json courrier 2025-05-04 22:20:29 +02:00
postcss.config.mjs Initial commit 2025-05-03 14:17:46 +02:00
README-MINIO-TROUBLESHOOTING.md missions carrousse 2025-05-06 10:59:38 +02:00
README.md dolibarr user 2025-05-04 10:15:48 +02:00
tailwind.config.ts Initial commit 2025-05-03 14:17:46 +02:00
tsconfig.json courrier 2025-05-04 22:20:29 +02:00
update-imports.js build fix 2025-05-05 13:04:01 +02:00
update-imports.sh build fix 2025-05-05 13:00:36 +02:00
yarn.lock courrier 2025-05-04 22:14:41 +02:00

Neah Email Application

A modern email client built with Next.js, featuring email composition, viewing, and management capabilities.

Email Processing Workflow

The application handles email processing through a centralized workflow:

  1. Email Fetching: Emails are fetched through the /api/courrier endpoints using user credentials stored in the database.

  2. Email Parsing: Raw email content is parsed using:

    • Server-side: parseEmail function from lib/server/email-parser.ts (which uses simpleParser from the mailparser library)
    • API route: /api/parse-email provides a REST interface to the parser
  3. HTML Sanitization: Email HTML content is sanitized and processed using:

    • sanitizeHtml function in lib/utils/email-utils.ts (centralized implementation)
    • DOMPurify with specific configuration to handle email content safely
  4. Email Display: Sanitized content is rendered in the UI with proper styling and security measures

  5. Email Composition: The ComposeEmail component handles email creation, replying, and forwarding

    • Email is sent through the /api/courrier/send endpoint

Key Features

  • Email Fetching and Management: Connect to IMAP servers and manage email fetching and caching logic
  • Email Composition: Rich text editor with reply and forwarding capabilities
  • Email Display: Secure rendering of HTML emails
  • Attachment Handling: View and download attachments

Project Structure

The project follows a modular structure:

  • /app - Next.js App Router structure with routes and API endpoints
  • /components - React components organized by domain
  • /lib - Core library code:
    • /server - Server-only code like email parsing
    • /services - Domain-specific services, including email service
    • /reducers - State management logic
    • /utils - Utility functions including the centralized email formatter

Technologies

  • Next.js 14+ with App Router
  • React Server Components
  • TailwindCSS for styling
  • Mailparser for email parsing
  • ImapFlow for email fetching
  • DOMPurify for HTML sanitization
  • Redis for caching

State Management

Email state is managed through React context and reducers, with server data fetched through React Server Components or client-side API calls as needed.

Email Formatting

Centralized Email Formatter

All email formatting is now handled by a centralized formatter in lib/utils/email-utils.ts. This ensures consistent handling of:

  • Reply and forward formatting
  • HTML sanitization
  • RTL/LTR text direction
  • MIME encoding and decoding for email composition

Key functions include:

  • formatForwardedEmail: Format emails for forwarding
  • formatReplyEmail: Format emails for replying
  • sanitizeHtml: Safely sanitize HTML email content
  • formatEmailForReplyOrForward: Compatibility function for both
  • decodeComposeContent: Parse MIME content for email composition
  • encodeComposeContent: Create MIME-formatted content for sending emails

This centralized approach prevents formatting inconsistencies and direction problems when dealing with emails in different languages.

Deprecated Functions

Several functions have been deprecated and removed in favor of centralized implementations:

  • Check the DEPRECATED_FUNCTIONS.md file for a complete list of deprecated functions and their replacements.

User Management API

The application provides endpoints for managing users in multiple systems:

  • Create User:

    • Endpoint: POST /api/users
    • Creates users in Keycloak, Leantime, and Dolibarr (if they have "mediation" or "expression" roles)
  • Update User:

    • Endpoint: PUT /api/users/[userId]
    • Updates user details in Keycloak
  • Delete User:

    • Endpoint: DELETE /api/users?id=[userId]&email=[userEmail]
    • Deletes users from Keycloak, Leantime, and Dolibarr systems
    • Important: Always include both id and email parameters for complete deletion across all systems
    • The legacy endpoint DELETE /api/users/[userId] forwards to the above endpoint
  • Manage Roles:

    • Endpoint: PUT /api/users/[userId]/roles
    • Updates user roles in Keycloak
  • Reset Password:

    • Endpoint: PUT /api/users/[userId]/password
    • Resets user password in Keycloak