-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! feat: add example contact on first login
Signed-off-by: Hamza Mahjoubi <[email protected]>
- Loading branch information
Showing
1 changed file
with
0 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
||
|
@@ -38,8 +36,6 @@ public function __construct( | |
private CalDavBackend $calDav, | ||
private CardDavBackend $cardDav, | ||
private Defaults $themingDefaults, | ||
private IAppManager $appManager, | ||
private UlidFactory $Uidfactory | ||
) { | ||
} | ||
|
||
|
@@ -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) { | ||
|
@@ -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]); | ||
} | ||
} | ||
} | ||
} | ||
} |