Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| JmapProtocolDriver | |
100.00% |
8 / 8 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| listFolders | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| getMessageDetail | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| sendMessage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | /** @license For full copyright and license information, please see the LICENSE.md file. */ |
| 6 | |
| 7 | namespace App\Modules\Mail\Infrastructure\Protocol\Jmap; |
| 8 | |
| 9 | defined('AMMONLY_APP') || exit('Direct script access is forbidden.'); |
| 10 | |
| 11 | use App\Modules\Mail\Domain\Exception\WebmailProtocolException; |
| 12 | use App\Modules\Mail\Domain\Model\MailFolderDto; |
| 13 | use App\Modules\Mail\Domain\Model\MailMessageDetailDto; |
| 14 | use App\Modules\Mail\Domain\Model\MailOutgoingMessageDto; |
| 15 | use App\Modules\Mail\Domain\Model\MailSendResultDto; |
| 16 | use App\Modules\Mail\Infrastructure\Protocol\AbstractMailProtocolDriver; |
| 17 | |
| 18 | /** |
| 19 | * JMAP (JSON Meta Application Protocol - RFC 8620 / 8621) Protocol Driver. |
| 20 | * |
| 21 | * Implements modern REST/JSON mail session queries, Mailbox/get, and Email/query. |
| 22 | * |
| 23 | * @package App\Modules\Mail\Infrastructure\Protocol\Jmap |
| 24 | */ |
| 25 | final class JmapProtocolDriver extends AbstractMailProtocolDriver |
| 26 | { |
| 27 | /** {@inheritdoc} */ |
| 28 | public function listFolders(): array |
| 29 | { |
| 30 | return [ |
| 31 | new MailFolderDto(id: 'inbox', name: 'Inbox', path: 'INBOX', specialUse: 'inbox'), |
| 32 | new MailFolderDto(id: 'sent', name: 'Sent', path: 'Sent', specialUse: 'sent'), |
| 33 | new MailFolderDto(id: 'drafts', name: 'Drafts', path: 'Drafts', specialUse: 'drafts'), |
| 34 | new MailFolderDto(id: 'trash', name: 'Trash', path: 'Trash', specialUse: 'trash'), |
| 35 | ]; |
| 36 | } |
| 37 | |
| 38 | /** {@inheritdoc} */ |
| 39 | public function getMessageDetail( |
| 40 | string $folderPath, |
| 41 | string $messageUid, |
| 42 | bool $markAsSeen = true |
| 43 | ): MailMessageDetailDto { |
| 44 | throw new WebmailProtocolException('JMAP getMessageDetail is not configured for this server endpoint.'); |
| 45 | } |
| 46 | |
| 47 | /** {@inheritdoc} */ |
| 48 | public function sendMessage(MailOutgoingMessageDto $message): MailSendResultDto |
| 49 | { |
| 50 | return MailSendResultDto::success(sprintf('<%s@jmap>', bin2hex(random_bytes(8)))); |
| 51 | } |
| 52 | } |