refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,7 @@
<?php
namespace App\Services\DavClient\Utils\Model;
class ContactDeleteDto extends ContactDto
{
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Services\DavClient\Utils\Model;
class ContactDto
{
/**
* @var string
*/
public $uri;
/**
* @var string|null
*/
public $etag;
/**
* Create a new ContactDto.
*
* @param string $uri
* @param string|null $etag
*/
public function __construct(string $uri, ?string $etag = null)
{
$this->uri = $uri;
$this->etag = $etag;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Services\DavClient\Utils\Model;
class ContactPushDto extends ContactUpdateDto
{
/**
* @var int
*/
public $mode;
public const MODE_MATCH_NONE = 0;
public const MODE_MATCH_ETAG = 1;
public const MODE_MATCH_ANY = 2;
/**
* @var int
*/
public $contactId;
/**
* Create a new ContactPushDto.
*
* @param string $uri
* @param string|null $etag
* @param string|resource $card
* @param int $mode
*/
public function __construct(string $uri, ?string $etag, $card, int $contact_id, int $mode = self::MODE_MATCH_NONE)
{
parent::__construct($uri, $etag, $card);
$this->mode = $mode;
$this->contactId = $contact_id;
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Services\DavClient\Utils\Model;
use function Safe\fclose;
use function Safe\stream_get_contents;
class ContactUpdateDto extends ContactDto
{
/**
* @var string
*/
public $card;
/**
* Create a new ContactUpdateDto.
*
* @param string $uri
* @param string|null $etag
* @param string|resource $card
*/
public function __construct(string $uri, ?string $etag, $card)
{
parent::__construct($uri, $etag);
$this->card = self::transformCard($card);
}
/**
* Transform card.
*
* @param string|resource $card
* @return string
*/
protected static function transformCard($card): string
{
if (is_resource($card)) {
$card = tap(stream_get_contents($card), function () use ($card) {
fclose($card);
});
}
return $card;
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Services\DavClient\Utils\Model;
use Illuminate\Support\Traits\Macroable;
use App\Models\Account\AddressBookSubscription;
use App\Services\DavClient\Utils\Dav\DavClient;
use App\Http\Controllers\DAV\Backend\CardDAV\CardDAVBackend;
/**
* @method array propFind($properties, int $depth = 0, array $options = [], string $url = '')
* @method array|string|null getProperty(string $property, string $url = '', array $options = [])
* @method array syncCollection($properties, string $syncToken, array $options = [], string $url = '')
* @method array addressbookQuery($properties, array $options = [], string $url = '')
*/
class SyncDto
{
use Macroable {
__call as macroCall;
}
/**
* @var AddressBookSubscription
*/
public $subscription;
/**
* @var DavClient
*/
public $client;
/**
* Sync the address book.
*/
public function __construct(AddressBookSubscription $subscription, DavClient $client)
{
$this->subscription = $subscription;
$this->client = $client;
}
/**
* Get address book name.
*
* @return string
*/
public function addressBookName(): string
{
return $this->subscription->addressbook->name;
}
/**
* Get carddav backend.
*
* @return CardDAVBackend
*/
public function backend(): CardDAVBackend
{
return app(CardDAVBackend::class)->init($this->subscription->user);
}
/**
* Execute a method against a new dav client instance.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (static::hasMacro($method)) {
return $this->macroCall($method, $parameters);
}
return $this->subscription->getClient()
->{$method}(...$parameters);
}
}