Skip to content

Commit

Permalink
fixup! feat: add example contact on first login
Browse files Browse the repository at this point in the history
Signed-off-by: Hamza Mahjoubi <[email protected]>
  • Loading branch information
hamza221 committed Jan 20, 2025
1 parent 8260a53 commit 53ab382
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions apps/dav/lib/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService;
use OCP\App\IAppManager;
use OCP\Defaults;
use OCP\IUser;
use OCP\IUserManager;
use Symfony\Component\Uid\Factory\UlidFactory;
use OCP\Util;
use Psr\Log\LoggerInterface;

Expand All @@ -38,8 +36,6 @@ public function __construct(
private CalDavBackend $calDav,
private CardDavBackend $cardDav,
private Defaults $themingDefaults,
private IAppManager $appManager,
private UlidFactory $Uidfactory
) {
}

Expand Down Expand Up @@ -132,7 +128,6 @@ public function changeUser($params) {
* @return void
*/
public function firstLogin(?IUser $user = null) {
\OC::$server->get(LoggerInterface::class)->error("First login");
if (!is_null($user)) {
$principal = 'principals/users/' . $user->getUID();
if ($this->calDav->getCalendarsForUserCount($principal) === 0) {
Expand All @@ -155,31 +150,6 @@ public function firstLogin(?IUser $user = null) {
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
}
}
$defaultAddressBook = $this->cardDav->getAddressBooksByUri($principal, CardDavBackend::PERSONAL_ADDRESSBOOK_URI);
\OC::$server->get(LoggerInterface::class)->error("default ab",[ 'defaultAddressBook' => $defaultAddressBook]);

if($defaultAddressBook != null) {
\OC::$server->get(LoggerInterface::class)->error("I'm here");
$cardData = 'BEGIN:VCARD' . PHP_EOL .
'VERSION:3.0' . PHP_EOL .
'PRODID:-//Nextcloud Contacts v' . $this->appManager->getAppVersion('contacts') . PHP_EOL .
'UID:'. $this->Uidfactory->create() . PHP_EOL .
'ADR;TYPE=HOME:;;123 Street Street;City;State;;Country' . PHP_EOL .
'EMAIL;TYPE=WORK:[email protected]' . PHP_EOL .
'TEL;TYPE=HOME,VOICE:+999999999999' . PHP_EOL .
'TITLE:Manager' . PHP_EOL .
'ORG:Company' . PHP_EOL .
'BDAY;VALUE=DATE:20000101' . PHP_EOL .
'URL;VALUE=URI:https://example.com/' . PHP_EOL .
'REV;VALUE=DATE-AND-OR-TIME:20241227T144820Z' . PHP_EOL .
'END:VCARD';
try{
$this->cardDav->createCard($defaultAddressBook['id'], 'Jane', $cardData,false);
}
catch(Exception $e){
\OC::$server->get(LoggerInterface::class)->error($e->getMessage(), ['exception' => $e]);
}
}
}
}
}

0 comments on commit 53ab382

Please sign in to comment.