- Add condition in MailDomainAdminViewSet.get_queryset() to return all domains
when user is both superuser and staff
- Add comprehensive tests covering all user permission combinations:
* superuser + staff: can see all domains
* superuser only: cannot see all domains (empty list)
* staff only: cannot see all domains (empty list)
* staff with domain access: can only see accessible domains
- Maintain existing behavior for regular users and domain admins
This change ensures that superusers with staff privileges have full
administrative access to all mail domains through the admin API,
while maintaining proper access control for other user types.
- 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.
- Add ability to search contacts by multiple keywords (AND logic)
on name and email, in contacts endpoint.
- Adapt and enrich tests to cover multi-word search,
case sensitivity, and name/email combination.
- Change label sorting from name-based to slug-based ordering in list view
- Use slug ordering for initial queryset to ensure consistent sorting
- Maintain name-based sorting in create method for consistency
- Fixes issue where "État civil et cimetière" appeared at the end
The slug-based sorting provides more predictable alphabetical ordering
since slugs are normalized versions of names without accents.
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.
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.
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.
- Add secondary ordering by created_at to prevent flaky test results
- When threads have the same messaged_at value, order by newest created_at first
- Ensures deterministic API responses for better test reliability
Add the ability to filter threads by label slug in the thread list endpoint. This feature
enables users to view all threads associated with a specific label.
Changes:
- Add label_slug query parameter to ThreadViewSet list endpoint
- Implement label-based filtering with proper permission checks
- Add OpenAPI documentation for the new label_id parameter
- Add comprehensive test suite for label filtering
Technical details:
- Filter threads by label while ensuring user has access to the label's mailbox
- Support combining label filter with existing filters (mailbox, search, etc.)
- Add proper error handling for invalid or inaccessible labels
- Add test coverage for various filtering scenarios:
- Single label filtering
- Combined label and mailbox filtering
- Invalid label handling
- Permission checks
- Combined filters (label + unread/starred status)
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
Avoid duplicate threads when importing the same file multiple times.
Changes:
- Moved duplicate message check to the start of deliver_inbound_message
- Maintains proper threading relationships while preventing duplicate threads
This ensures that:
- No duplicate threads are created when importing the same file multiple times
Test coverage:
- Updated existing import tests to check thread counts
- Verified that duplicate imports don't create new threads
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
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.
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.
Improve the description of the blob api endpoint then regenerate
schema and client api through `make api-update`. Furthermore we
also update FetchApi interface to manage boundary multipart content type
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.
Previously we expect the task retrieve endpoint could return a 404 when a task
does not exist but it is not possible (dce87f8) so instead we put a timeout to
stop to poll the task after a given delay.
Before, sending was done synchronously on the api/send POST call. Now
we just build the MIME message and mark the message for sending, and
queue the actual SMTP (or internal) sending for the worker. We use
this opportunity to add fine-grained delivery statuses for each
recipient, something that traditional email systems are unable to do!
Expanding on that, this (too large) PR adds an initial Elasticsearch
index of threads. It also overhauls the build and CI system, using
Poetry instead of Pip.
* ✨(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
The api allows us to filter threads through filters. We are using this new
feature to build dynamic folders (All threads, Drafts, Send and Trash).
Furthermore we update the MessageForm logic to stick with the new draft
logic (First create a draft message then send the message)