Commit Graph
65 Commits
Author SHA1 Message Date
Stanislas BruhièreandGitHub 02bce211ea ✨(frontend) add a button and modal to create maildomains (#313)
* ✨(feat) create modal, serializer and add button

* ✨(frontend) refetch on domain creation

* 🚨(frontend) fix linter

* ✅(backend) add domain creation test

* ✨(frontend) add toaster for domain creation

* 💬(frontend) add translation and fix small typo

* ✨(front+back) add custom_attributes on domain creation

* 💄(frontend) add style for create domain modal

* 💬(frontend) add missing translations + add end of file line breaks

* 🎨(frontend) move toaster to admin layout

* 🦺(frontend) validate domain name in frontend

* 💄(frontend) remove unused css

* ✅(backend) add more tests

* 🎨(backend) improve maildomain structure

* 🎨(frontend) follow nitpicks
2025-09-02 20:13:11 +02:00
Fabian ArfireandJean-Baptiste PENRATH cdb4e207e5 ✨(backend) add auto labelling ai feature
When a message is received, if the auto labelling feature is enabled,
we try to add all relevant labels that are flagged for auto labelling to this
message.

Co-authored-by: jbpenrath <jb.penrath@gmail.com>
2025-08-19 23:48:03 +02:00
jbpenrath 53110862d6 ✨(front) manage abilities
Improve openapi schema to pass abilities to frontend properly.
Then through the useAbility hook, hide/disable actions.
It concerns actions to send messages, write messages, share
thread access, crud labels, crud maildomain mailboxes.
2025-08-07 10:39:23 +02:00
jbpenrath d0b2a66f08 🐛(frontend) draftBody can be null
There was an error in the openapi schema and we are not aware that
message.draftBody could be null so when it was the case, the frontend
throws an error when rendering the `MessageForm` component.
2025-08-06 10:12:36 +02:00
jbpenrath 7c07711489 👽️(openapi) improve user definition with or without abilities
The OpenAPI Schema does not embedded abilities property.
We fix that and make two serializers for User model in order to get proper
openapi definition for User instance with abilities and without abilities.
2025-07-31 17:19:23 +02:00
Sabrina Demagny 6d6bbea0d9 ✨(imap) improve IMAP import code, load folders for GMAIL and ORANGE
- Load folders for GMAIL and ORANGE
- Fix read issue with Gmail IMAP import (all messages were marked as read)
- Fix IMAP encoding for Gmail import
- Refactor monolithic import_imap_messages_task into smaller, focused functions
- Add IMAPConnectionManager context manager for better resource management
- Extract helper functions with single responsibilities

This refactoring improves code maintainability, readability, and testability
while maintaining backward compatibility with existing API.
2025-07-28 11:18:28 +02:00
Mathis ROUGETandJean-Baptiste PENRATH e32862e4b3 ✨(ai) add thread summary 2025-07-24 11:45:07 +02:00
Sabrina Demagny 65af318fb5 ✨(backend) add get_abilities for Mailbox
- Add pre-calculation of user access roles in MailboxViewSet list/retrieve methods
- Implement get_abilities method on Mailbox model for permission checking
- Add AbilitiesModelSerializer to MailboxSerializer for consistent abilities field
- Optimize database queries by reducing N+1 access lookups
- Add comprehensive test coverage for abilities and optimized queries

This optimization significantly reduces database queries when listing
mailboxes by pre-calculating user roles instead of querying for each
mailbox individually.
2025-07-22 09:34:09 +02:00
Sylvain ZimmerandGitHub 9b4ba9ba09 ✨(dns) add admin page for DNS records (#283)
* ✨(dns) add admin page for DNS records. Fixes #177

* 👷(dockerflow) add a flag to disable Dockerflow

* 💚(ghactions) fix check-api-update that was missing Orval

* 💚(ci) fix tests that depended on Keycloak

* ♻️(admin) refactor CopyableInput into a separate component

* 🎨(dns) improve code style
2025-07-21 14:41:08 +02:00
Sylvain ZimmerandGitHub cc858e75e4 ✨(admin) improve Admin mailbox management page (#284)
This fixes a few small anoyances and adds a new field Mailbox.is_identity
to the models so that we can save what type of mailbox the admin created.
2025-07-21 10:47:06 +02:00
Sylvain ZimmerandSabrina Demagny 4545f4ff48 ✨(roles) implement MailboxAccessRole.SENDER 2025-07-18 14:11:29 +02:00
Sylvain Zimmer cfb417d80b 🐛(admin) add the ability to add mailbox accesses by email
This fixes the admin panel where users searched among the same
maildomain could correctly be added by their uuid, but when entering
an arbitrary email, the email and not the uuid gets sent in the POST
mailbox access. This might get replaced later when we have a proper
invitation system for external emails.
2025-07-18 00:00:00 +02:00
jbpenrath 97c55bd7f0 🏷️(global) fix openapi schema and typescript types
Enhance the `IntegerChoicesField` to be well interpreted by drf
spectacular to generate a clean OpenAPI Schema then fix Typescript
issues once the api types have been fixed.
2025-07-16 15:04:26 +02:00
Sylvain ZimmerandGitHub f1a89a5bdb ✨(all) refactor several areas before 0.1 release (#265)
We are going to release a 0.1 version soon, along with our first production deployment. Starting from there, migrations and a consistent developer experience will be officially supported. To make that easier, this large patch cleans up several areas:
 * Reset migrations one last time
 * Update models for storage efficiency (move textchoices to integerchoices on high-volume tables)
 * Use Blobs for mail mime data and draft bodies. Having them in a separate PG table is a first step, we will later start offloading them to object storage.
 * Add default ZSTD compression to blobs
 * Add per-domain DKIM Keys
 * Add DNS check and provisioning, with a first Scaleway provider
 * Fix Keycloak user provisioning
 * Fix Attachment storage, they are now stored individually only at the drafting stage. Afterwards they are extracted from the main blob. This may be optimized later but at least we only store once. For JMAP compatibility, this requires using fake IDs in the blob API route.
 * Add a management command and recurring task to retry unsent messages
 * Improve the local developer experience with new ports and make commands
 * Repackage MTA-in and MTA-out to be closer to Backend: Poetry, multi-step Dockerfile, move compose and makefile to the root
 * Migrate to OpenSearch
 * Improve overall documentation and add a self-hosting page

Contributes to #177 and #185
2025-07-15 10:41:55 +02:00
Sabrina Demagny e1940295dc ✨(api) add dynamic abilities field to MailDomain API
- Add get_abilities() method to MailDomain model for permission-based abilities
- Update MailDomainAdminSerializer to inherit from AbilitiesModelSerializer
- Add RetrieveModelMixin to MailDomainAdminViewSet for detail endpoints
- Optimize queries with JOIN and annotation for regular users
- Add prefetch_related for superusers to avoid N+1 queries
- Add comprehensive tests for abilities functionality and query optimization
- Add new test file for MailDomain model abilities

The abilities field dynamically controls user permissions based on their role
in the mail domain, with optimized database queries to maintain performance.
2025-07-11 12:36:20 +02:00
jbpenrathandSylvain Zimmer 0c44e7803a ✨(backend) complete admin maildomain api
- Create user (if needed) and mailbox access on mailbox creation
- If identify provider is keycloak, generate a one time password
at mailbox creation
- At nested endpoint to search users related to a maildomain

Co-authored-by: Sylvain Zimmer <sylvain@sylvainzimmer.com>
2025-07-10 18:05:00 +02:00
Sabrina Demagny b1daf05da6 ✨(api) add AbilitiesModelSerializer with exclude_abilities option
- Create AbilitiesModelSerializer base class that dynamically controls abilities field inclusion
- Refactor UserSerializer to inherit from AbilitiesModelSerializer
- Add exclude_abilities parameter to prevent abilities serialization in nested contexts
- Update MailboxAccessReadSerializer and MailboxAccessNestedUserSerializer to exclude abilities when nested
- Remove abilities from UserSerializer Meta fields as it's now handled dynamically
2025-07-10 17:18:55 +02:00
Sabrina Demagny d3df815d1f ✨(backend) add user abilities system for mail domain permissions
- Add get_abilities() method to User model to determine user permissions
- Add abilities field to UserSerializer to expose permissions via API
- Implement permission logic for create_maildomains and view_maildomains
- Add comprehensive tests for User model abilities method
- Add integration tests for abilities field in users/me endpoint
- Support superuser+staff, mail domain access, and regular user scenarios

The abilities system provides granular permission control for mail domain
operations, allowing the frontend to adapt UI based on user capabilities.
2025-07-10 14:34:49 +02:00
Sabrina Demagny 1688ef70f7 💚(lint) run make lint 2025-06-23 11:44:23 +02:00
jbpenrath 6beac632b6 ✨(front) list labels in left panel and allow to edit them
Load and display labels in left panel. Add also a modal to
create/edit/delete labels.
2025-06-20 00:58:11 +02:00
Sabrina Demagny b2b71cc405 🐛(api) fix partial update of label 2025-06-20 00:15:35 +02:00
Sabrina DemagnyandJean-Baptiste PENRATH eee7afa65c ✨(backend) upload blob for eml and mbox import 2025-06-20 00:13:50 +02:00
Sabrina Demagny ce945259c8 💚(lint) run make lint
A `make lint` run was forgotten in the last commit
2025-06-19 13:45:09 +02:00
jbpenrath 0d4e4f3536 💄(front) clean a little bit label badges
We recently display label badges into thread-item. We revamp that
a little bit to improve code structure and prepare the layout
for further improvements.
2025-06-19 02:05:41 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH 6fd271bed8 ♻️(flags) refactor Thread flags and stats
Migrate from counters to simple flags, because the frontend needs
counts of threads, not sums of counts of messages. Also prepare
for spam and archive features.
2025-06-19 02:05:41 +02:00
Sabrina Demagny e18732bb47 ♻️(labels) move parent labels creation logic
Put the logic into Label model's save() method to guarantee the invariant always holds,
even when using the admin interfacee uses, the shell, bulk operations, or any code path.
2025-06-18 11:21:03 +02:00
Sylvain ZimmerandGitHub 460068b5d3 ✨(identity) add MailDomain management with Keycloak identity provider (#136)
This allows user creation, passwords reset and listing users from
Keycloak, plus a new MailDomainAccess model for admins.

* ✨(admin) add maildomainacess model, api route and backend tests

* ♻️(drf) simplify API code

* ✨(keycloack) add deployable keycloak to PaaS

* ✨(keycloak) add integration via API, upgrade to 26.x

* 🗑️(settings) remove invitation setting

* 🐛(tests) fix failing tests after rebase

* 🚨(all) fix lint
2025-06-16 10:03:40 +02:00
Sabrina Demagny 2ff790afb1 ✨(api) add endpoints to manage labels
This commit implements a complete label management system with the following features:

- Add CRUD operations for labels with hierarchical support (using slash-based naming)
- Implement label-thread associations (add/remove threads to/from labels)
- Add comprehensive permission checks (ADMIN/EDITOR roles required for management)
- Support hierarchical label structure with automatic parent creation
- Add color customization for labels
- Implement proper slug generation for label names
- Add extensive test coverage for all label operations

Technical details:
- New LabelViewSet with list, create, update, delete operations
- Custom actions for thread management (add-threads, remove-threads)
- Hierarchical label structure with parent-child relationships
- Automatic parent label creation when creating nested labels
- Proper permission handling based on mailbox access roles
- Comprehensive test suite covering all edge cases
- OpenAPI documentation for all endpoints
2025-06-15 18:18:31 +02:00
Sabrina Demagny c297137bf4 ✨(backend) improve MBOX file import compatibility
Enhance support for MBOX files from various email export tools by handling
both extensionless files and text/plain MIME type. This improves compatibility
with different export formats while maintaining security through proper
validation.

Changes:
- Add support for files named "mbox" without extension
- Allow text/plain MIME type for MBOX files (common in webmail exports)
- Keep application/mbox as the primary MIME type for MBOX files
- Update validation to check both MIME types and file extensions
- Add test cases for extensionless files and text/plain MIME type
- Update error messages to be more descriptive about supported formats

The validation now handles:
- Files with .mbox extension (application/mbox or text/plain MIME type)
- Files named "mbox" without extension
- Maintains strict validation to ensure text/plain is only accepted for MBOX files

This change improves compatibility with various email export tools and webmail
services while maintaining security through proper file validation.
2025-06-15 15:13:38 +02:00
Sabrina Demagny c603350703 ✨(api) add labels info on Thread
Add details of labels info on thread list
2025-06-11 09:38:56 +02:00
Sabrina Demagny 55a7b1e49f ✨(api) add endpoints to import messages
Refactor code to import messages and add endpoints to import messages
(.eml, .mbox, imap)
2025-06-05 18:23:10 +02:00
jbpenrath db7631fd67 👽️(openapi) fix thread access serializer type and update schema and api
The `accesses` property into the Thread object was not propertly typed so we
update the serializer to fix the type by using dedicated sub serializers then we
run `make api-update` to update schema and api client.
2025-05-26 15:54:37 +02:00
Sylvain ZimmerandGitHub 3259eb07a6 ✨(admin) add maildomainaccess model, api route and backend tests (#102)
* ✨(admin) add maildomainacess model, api route and backend tests

* ♻️(drf) simplify API code
2025-05-21 22:21:45 +02:00
Sabrina Demagny 3e98509dcc ✨(api) add endpoint to search Mailboxes
Allow to search Mailboxes from same domain of a context Mailbox.
2025-05-20 01:25:49 +02:00
Sabrina Demagny 7d8500ac22 ✨(backend) link a Mailbox to a Contact instance
Add FK to Contact on Mailbox model.
Display name of mailbox contact into list accesses of a thread
2025-05-19 20:24:22 +02:00
Sabrina Demagny 2c2eb3a39b Revert "✨(backend) enhance Mailbox model to add a display name"
This reverts commit c5d1ee220e.
2025-05-19 14:45:26 +02:00
Sabrina Demagny c5d1ee220e ✨(backend) enhance Mailbox model to add a display name
Add an optional name field
2025-05-19 13:04:26 +02:00
Sabrina Demagny 65db4fddad ✨(api) enhance Thread serializer to return thread accesses
Add list of thread accesses into Thread serializer
2025-05-19 12:55:05 +02:00
jbpenrath c61ba946fa 👽️(api) add thread_id property to Message resource
Frontend needs to be able to retrieve the thread_id of a message
so we tweak the MessageSerializer to bind this information. Then we run
`make api-update` to update api schema and client.
2025-05-19 11:16:03 +02:00
Sabrina Demagny eca469e666 ✨(api) add endpoint to manage ThreadAccess
Allows creating, updating, and deleting access to threads based on
user role.
2025-05-16 12:18:14 +02:00
Sylvain ZimmerandGitHub 87a949d4d2 ✨(attach) add initial attachments support in in/outbound & api (#93) 2025-05-15 13:45:52 +02:00
Sabrina Demagny a99b2a0fae 🐛(backend) fix bcc lost after updated draft
Enhance and fix check to allow bcc displaying. Fix #85
2025-05-14 20:35:49 +02:00
Sabrina DemagnyandGitHub 84f95bf52a ✨(backend) use ThreadAccess instead of direct mailbox link (#80)
* ✨(backend) use ThreadAccess instead of direct mailbox link

Remove the direct link to a mailbox on Thread model. It is now possible to
define two types of roles for each thread (Reader and Editor) for a mailbox.
When creating a new thread, a new access to the sender's mailbox is created
with the Editor role.
It is now possible to delegate a thread to another mailbox with the Reader or
Editor role. So it is possible to forward a thread to another internal user
and avoid mail forwarding.

* ✨(backend) change MailboxAccess permission into roles

Enhance access on mailbox and thread with role everywhere!

* improve doc

* enhance tests

* lint
2025-05-12 21:29:06 +02:00
jbpenrath 715f040123 👽️(api) update schema and api client
Run `make api-update`
2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH 869ec6187a ✨(api) add parent_id in message serializer 2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH 81a8718cc5 🐛(drafts) add draftBody in message view 2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH fed2d52c72 ♻️(thread) continue improving thread stats 2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH baa6ff8964 🚨(lint) fix lint 2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH bf3df3a658 ✨(api) add threads.count_messages and messaged_at 2025-04-30 22:06:29 +02:00
Sylvain ZimmerandJean-Baptiste PENRATH 17b86ad5db ♻️(flags) refactor "read" and "thread.delete" feature in a single flag route 2025-04-30 22:06:29 +02:00