Summary
Introduce a protocol abstraction layer that enables the service layer to route operations to
either IMAP or JMAP client factories based on the account's configured protocol.
Problem
The service layer is currently tightly coupled to IMAP. To support multiple protocols,
the codebase needs a way to route client instantiation and key operations based on account configuration.
Solution
- Add
protocol_type column to mail_accounts table (default: 'imap' for existing accounts)
- Create
ProtocolClientFactory dispatcher
- Refactor existing code to use dispatcher for client instantiation
- Update account creation API to accept protocol parameter
- Ensure existing IMAP accounts continue working
Implementation
Database migration adds protocol_type enum column ('imap' | 'jmap', default: 'imap').
Services query account protocol before instantiating clients:
$client = $this->protocolClientFactory->getClient($account);
The dispatcher checks $account->getProtocol() and returns the appropriate client factory.
Account API endpoint accepts optional protocol parameter (defaults to 'imap').
Affected Components
- Database: migration for
mail_accounts table
MailAccount entity: add protocol field
MailManager, SyncService: use dispatcher
AccountsController: accept protocol parameter
- New:
ProtocolClientFactory dispatcher
Out of Scope
- Authentication method selection (OAuth, etc.)
- Protocol auto-detection
Summary
Introduce a protocol abstraction layer that enables the service layer to route operations to
either IMAP or JMAP client factories based on the account's configured protocol.
Problem
The service layer is currently tightly coupled to IMAP. To support multiple protocols,
the codebase needs a way to route client instantiation and key operations based on account configuration.
Solution
protocol_typecolumn tomail_accountstable (default: 'imap' for existing accounts)ProtocolClientFactorydispatcherImplementation
Database migration adds
protocol_typeenum column ('imap' | 'jmap', default: 'imap').Services query account protocol before instantiating clients:
The dispatcher checks
$account->getProtocol()and returns the appropriate client factory.Account API endpoint accepts optional
protocolparameter (defaults to 'imap').Affected Components
mail_accountstableMailAccountentity: add protocol fieldMailManager,SyncService: use dispatcherAccountsController: accept protocol parameterProtocolClientFactorydispatcherOut of Scope