fix:(dav): add note to example contact

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
This commit is contained in:
Hamza 2026-03-11 11:11:12 +01:00
parent a304a54775
commit 9f5c3e39a7
2 changed files with 9 additions and 0 deletions

View file

@ -15,6 +15,7 @@ use OCP\AppFramework\Services\IAppConfig;
use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\IL10N;
use Psr\Log\LoggerInterface;
use Symfony\Component\Uid\Uuid;
@ -26,6 +27,7 @@ class ExampleContactService {
private readonly IAppConfig $appConfig,
private readonly LoggerInterface $logger,
private readonly CardDavBackend $cardDav,
private readonly IL10N $l,
) {
$this->appData = $appDataFactory->get(Application::APP_ID);
}
@ -131,6 +133,9 @@ class ExampleContactService {
} else {
$vcard->add('REV', $newRev);
}
if (!$vcard->Note) {
$vcard->add('note', $this->l->t('This is an example contact'));
}
// Level 3 means that the document is invalid
// https://sabre.io/vobject/vcard/#validating-vcard

View file

@ -18,6 +18,7 @@ use OCP\Files\IAppData;
use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile;
use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IL10N;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Symfony\Component\Uid\Uuid;
@ -31,6 +32,7 @@ class ExampleContactServiceTest extends TestCase {
protected LoggerInterface&MockObject $logger;
protected IAppConfig&MockObject $appConfig;
protected IAppData&MockObject $appData;
protected IL10N&MockObject $l;
protected function setUp(): void {
parent::setUp();
@ -39,6 +41,7 @@ class ExampleContactServiceTest extends TestCase {
$this->appDataFactory = $this->createMock(IAppDataFactory::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->appConfig = $this->createMock(IAppConfig::class);
$this->l = $this->createMock((IL10N::class));
$this->appData = $this->createMock(IAppData::class);
$this->appDataFactory->method('get')
@ -50,6 +53,7 @@ class ExampleContactServiceTest extends TestCase {
$this->appConfig,
$this->logger,
$this->cardDav,
$this->l,
);
}