Skip to content

Commit 03c45e0

Browse files
feat: jmap support - initial
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
1 parent 54db1fd commit 03c45e0

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

composer.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/Contracts/IMessageConnector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
use OCA\Mail\Attachment;
1414
use OCA\Mail\Db\Mailbox;
1515
use OCA\Mail\Model\IMAPMessage;
16+
use OCA\Mail\Protocol\SyncResult;
1617
use OCA\Mail\Service\Quota;
1718

1819
interface IMessageConnector {
1920

2021
/**
2122
* Perform a differential sync for the given mailbox.
2223
*/
23-
public function syncMessages(Account $account, Mailbox $mailbox, bool $force = false): void;
24+
public function syncMessages(Account $account, Mailbox $mailbox, bool $force = false): SyncResult;
2425

2526
/**
2627
* Fetch a single message envelope (and optionally its body).
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-only
8+
*/
9+
10+
namespace OCA\Mail\Tests\Integration\Protocol;
11+
12+
use ChristophWurst\Nextcloud\Testing\TestCase;
13+
use Horde_Imap_Client_Socket;
14+
use JmapClient\Client as JmapClient;
15+
use OCA\Mail\Protocol\ProtocolFactory;
16+
use OCA\Mail\Tests\Integration\Framework\ImapTestAccount;
17+
use OCA\Mail\Tests\Integration\Framework\JmapTestAccount;
18+
use OCP\Server;
19+
20+
class ProtocolFactoryTest extends TestCase {
21+
use ImapTestAccount;
22+
use JmapTestAccount;
23+
24+
private ProtocolFactory $protocolFactory;
25+
26+
protected function setUp(): void {
27+
parent::setUp();
28+
29+
$this->protocolFactory = Server::get(ProtocolFactory::class);
30+
}
31+
32+
public function testImapClientConnection(): void {
33+
$account = $this->createTestAccount();
34+
35+
$client = $this->protocolFactory->imapClient($account);
36+
37+
$this->assertInstanceOf(Horde_Imap_Client_Socket::class, $client);
38+
$client->login();
39+
$client->logout();
40+
}
41+
42+
public function testJmapClientConnection(): void {
43+
$account = $this->createTestAccount();
44+
45+
$client = $this->protocolFactory->jmapClient($account);
46+
47+
$this->assertInstanceOf(JmapClient::class, $client);
48+
49+
$session = $client->connect();
50+
51+
$this->assertTrue($client->sessionStatus(), 'JMAP session should be established');
52+
$this->assertNotEmpty($session->username(), 'Session should report a username');
53+
$this->assertNotEmpty($session->commandUrl(), 'Session should provide an API URL');
54+
}
55+
}

0 commit comments

Comments
 (0)