feat(ocp): create contacts from string

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
This commit is contained in:
Richard Steinmetz 2025-08-29 11:02:16 +02:00
parent 5a73733ec1
commit 16ad73cd15
No known key found for this signature in database
GPG key ID: 27137D9E7D273FB2
4 changed files with 38 additions and 1 deletions

View file

@ -10,13 +10,14 @@ namespace OCA\DAV\CardDAV;
use OCA\DAV\Db\PropertyMapper;
use OCP\Constants;
use OCP\IAddressBookEnabled;
use OCP\ICreateContactFromString;
use OCP\IURLGenerator;
use Sabre\VObject\Component\VCard;
use Sabre\VObject\Property;
use Sabre\VObject\Reader;
use Sabre\VObject\UUIDUtil;
class AddressBookImpl implements IAddressBookEnabled {
class AddressBookImpl implements IAddressBookEnabled, ICreateContactFromString {
/**
* AddressBookImpl constructor.
@ -336,4 +337,8 @@ class AddressBookImpl implements IAddressBookEnabled {
}
return true;
}
public function createFromString(string $name, string $vcfData): void {
$this->backend->createCard($this->getKey(), $name, $vcfData);
}
}

View file

@ -606,6 +606,7 @@ return array(
'OCP\\ICertificateManager' => $baseDir . '/lib/public/ICertificateManager.php',
'OCP\\IConfig' => $baseDir . '/lib/public/IConfig.php',
'OCP\\IContainer' => $baseDir . '/lib/public/IContainer.php',
'OCP\\ICreateContactFromString' => $baseDir . '/lib/public/ICreateContactFromString.php',
'OCP\\IDBConnection' => $baseDir . '/lib/public/IDBConnection.php',
'OCP\\IDateTimeFormatter' => $baseDir . '/lib/public/IDateTimeFormatter.php',
'OCP\\IDateTimeZone' => $baseDir . '/lib/public/IDateTimeZone.php',

View file

@ -647,6 +647,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\ICertificateManager' => __DIR__ . '/../../..' . '/lib/public/ICertificateManager.php',
'OCP\\IConfig' => __DIR__ . '/../../..' . '/lib/public/IConfig.php',
'OCP\\IContainer' => __DIR__ . '/../../..' . '/lib/public/IContainer.php',
'OCP\\ICreateContactFromString' => __DIR__ . '/../../..' . '/lib/public/ICreateContactFromString.php',
'OCP\\IDBConnection' => __DIR__ . '/../../..' . '/lib/public/IDBConnection.php',
'OCP\\IDateTimeFormatter' => __DIR__ . '/../../..' . '/lib/public/IDateTimeFormatter.php',
'OCP\\IDateTimeZone' => __DIR__ . '/../../..' . '/lib/public/IDateTimeZone.php',

View file

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP;
use OCP\AppFramework\Attribute\Consumable;
/**
* Create a new contact in an address book from a serialized vCard.
*
* @since 32.0.0
*/
#[Consumable(since: '32.0.0')]
interface ICreateContactFromString extends IAddressBook {
/**
* Create a new contact in this address book.
*
* @param string $name The name or uri of the vCard to be created. Should have a vcf file extension.
* @param string $vcfData The raw, serialized vCard data.
*
* @since 32.0.0
*/
public function createFromString(string $name, string $vcfData): void;
}