Skip to content

Commit 8598aad

Browse files
hamza221backportbot[bot]
authored andcommitted
fix:(dav): add note to example contact
Signed-off-by: Hamza <[email protected]>
1 parent a32b8a2 commit 8598aad

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

apps/dav/lib/Service/ExampleContactService.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use OCP\Files\AppData\IAppDataFactory;
1616
use OCP\Files\IAppData;
1717
use OCP\Files\NotFoundException;
18+
use OCP\IL10N;
1819
use Psr\Log\LoggerInterface;
1920
use Symfony\Component\Uid\Uuid;
2021

@@ -26,6 +27,7 @@ public function __construct(
2627
private readonly IAppConfig $appConfig,
2728
private readonly LoggerInterface $logger,
2829
private readonly CardDavBackend $cardDav,
30+
private readonly IL10N $l,
2931
) {
3032
$this->appData = $appDataFactory->get(Application::APP_ID);
3133
}
@@ -131,6 +133,9 @@ public function createDefaultContact(int $addressBookId): void {
131133
} else {
132134
$vcard->add('REV', $newRev);
133135
}
136+
if (!$vcard->Note) {
137+
$vcard->add('note', $this->l->t('This is an example contact'));
138+
}
134139

135140
// Level 3 means that the document is invalid
136141
// https://sabre.io/vobject/vcard/#validating-vcard

apps/dav/tests/unit/Service/ExampleContactServiceTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\Files\NotFoundException;
1919
use OCP\Files\SimpleFS\ISimpleFile;
2020
use OCP\Files\SimpleFS\ISimpleFolder;
21+
use OCP\IL10N;
2122
use PHPUnit\Framework\MockObject\MockObject;
2223
use Psr\Log\LoggerInterface;
2324
use Symfony\Component\Uid\Uuid;
@@ -31,6 +32,7 @@ class ExampleContactServiceTest extends TestCase {
3132
protected LoggerInterface&MockObject $logger;
3233
protected IAppConfig&MockObject $appConfig;
3334
protected IAppData&MockObject $appData;
35+
protected IL10N&MockObject $l;
3436

3537
protected function setUp(): void {
3638
parent::setUp();
@@ -39,6 +41,7 @@ protected function setUp(): void {
3941
$this->appDataFactory = $this->createMock(IAppDataFactory::class);
4042
$this->logger = $this->createMock(LoggerInterface::class);
4143
$this->appConfig = $this->createMock(IAppConfig::class);
44+
$this->l = $this->createMock((IL10N::class));
4245

4346
$this->appData = $this->createMock(IAppData::class);
4447
$this->appDataFactory->method('get')
@@ -50,6 +53,7 @@ protected function setUp(): void {
5053
$this->appConfig,
5154
$this->logger,
5255
$this->cardDav,
56+
$this->l,
5357
);
5458
}
5559

0 commit comments

Comments
 (0)