1
0
Fork 0

use container to allow dependency injection in transport classes

This commit is contained in:
Jonathan Treffler 2024-07-23 02:10:32 +02:00
parent f994a182d3
commit ec6e69e240
2 changed files with 8 additions and 6 deletions

View file

@ -43,14 +43,13 @@ class SubscriptionService {
}
}
public function create(string $userId, string $collectionName, string $transport, int $expirationTimestamp, $data, ?int $creationTimestamp = null) {
public function create(string $userId, string $collectionName, string $transport, int $expirationTimestamp, ?int $creationTimestamp = null) {
$subscription = new Subscription();
$subscription->setUserId($userId);
$subscription->setCollectionName($collectionName);
$subscription->setTransport($transport);
$subscription->setCreationTimestamp($creationTimestamp ?? time());
$subscription->setExpirationTimestamp($expirationTimestamp);
$subscription->setData(json_encode($data));
$subscription = $this->mapper->insert($subscription);
return $subscription;

View file

@ -27,18 +27,21 @@ declare(strict_types=1);
namespace OCA\DavPush\Transport;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Server;
use OCA\DavPush\Events\RegisterTransportsEvent;
use OCA\DavPush\PushTransports\WebPushTransport;
use OCA\DavPush\PushTransports\WebhookTransport;
//use OCA\DavPush\PushTransports\WebhookTransport;
class TransportManager {
private array $transports = [];
public function __construct(IEventDispatcher $dispatcher) {
public function __construct(
IEventDispatcher $dispatcher,
) {
// register integrated transports
$this->registerTransport(new WebPushTransport());
$this->registerTransport(new WebhookTransport());
$this->registerTransport(Server::get(WebPushTransport::class));
//$this->registerTransport(ContainerInterface::get(WebhookTransport::class));
// register transports provided by other apps
$event = new RegisterTransportsEvent($this);