2022-04-14 00:39:31 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Event;
|
|
|
|
|
|
|
|
use Utopia\Database\Document;
|
2022-12-14 00:16:12 +13:00
|
|
|
use Utopia\Queue\Client;
|
|
|
|
use Utopia\Queue\Connection;
|
2022-04-14 00:39:31 +12:00
|
|
|
|
|
|
|
class Certificate extends Event
|
|
|
|
{
|
2022-05-12 05:05:43 +12:00
|
|
|
protected bool $skipRenewCheck = false;
|
2022-04-19 04:21:45 +12:00
|
|
|
protected ?Document $domain = null;
|
2022-04-14 00:39:31 +12:00
|
|
|
|
2022-12-14 00:16:12 +13:00
|
|
|
public function __construct(protected Connection $connection)
|
2022-04-14 00:39:31 +12:00
|
|
|
{
|
2023-06-02 15:54:34 +12:00
|
|
|
parent::__construct($connection);
|
|
|
|
|
|
|
|
$this
|
|
|
|
->setQueue(Event::CERTIFICATES_QUEUE_NAME)
|
|
|
|
->setClass(Event::CERTIFICATES_CLASS_NAME);
|
2022-04-14 00:39:31 +12:00
|
|
|
}
|
|
|
|
|
2022-04-19 04:21:45 +12:00
|
|
|
/**
|
|
|
|
* Set domain for this certificates event.
|
|
|
|
*
|
2022-05-11 00:31:20 +12:00
|
|
|
* @param Document $domain
|
2022-04-19 04:21:45 +12:00
|
|
|
* @return self
|
|
|
|
*/
|
2022-04-14 00:39:31 +12:00
|
|
|
public function setDomain(Document $domain): self
|
|
|
|
{
|
|
|
|
$this->domain = $domain;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-04-19 04:21:45 +12:00
|
|
|
/**
|
|
|
|
* Returns the set domain for this certificate event.
|
|
|
|
*
|
2022-05-11 00:31:20 +12:00
|
|
|
* @return null|Document
|
2022-04-19 04:21:45 +12:00
|
|
|
*/
|
2022-04-14 00:39:31 +12:00
|
|
|
public function getDomain(): ?Document
|
|
|
|
{
|
|
|
|
return $this->domain;
|
|
|
|
}
|
|
|
|
|
2022-04-19 04:21:45 +12:00
|
|
|
/**
|
2022-05-12 05:05:43 +12:00
|
|
|
* Set if the certificate needs to be validated.
|
2022-04-19 04:21:45 +12:00
|
|
|
*
|
2022-05-12 05:05:43 +12:00
|
|
|
* @param bool $skipRenewCheck
|
2022-04-19 04:21:45 +12:00
|
|
|
* @return self
|
|
|
|
*/
|
2022-05-12 05:05:43 +12:00
|
|
|
public function setSkipRenewCheck(bool $skipRenewCheck): self
|
2022-04-14 00:39:31 +12:00
|
|
|
{
|
2022-05-12 05:05:43 +12:00
|
|
|
$this->skipRenewCheck = $skipRenewCheck;
|
2022-04-14 00:39:31 +12:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2022-04-19 04:21:45 +12:00
|
|
|
/**
|
2022-05-12 05:05:43 +12:00
|
|
|
* Return if the certificate needs be validated.
|
2022-04-19 04:21:45 +12:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2022-05-12 05:05:43 +12:00
|
|
|
public function getSkipRenewCheck(): bool
|
2022-04-14 00:39:31 +12:00
|
|
|
{
|
2022-05-12 05:05:43 +12:00
|
|
|
return $this->skipRenewCheck;
|
2022-04-14 00:39:31 +12:00
|
|
|
}
|
|
|
|
|
2022-04-19 04:21:45 +12:00
|
|
|
/**
|
|
|
|
* Executes the event and sends it to the certificates worker.
|
|
|
|
*
|
|
|
|
* @return string|bool
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
2022-04-14 00:39:31 +12:00
|
|
|
public function trigger(): string|bool
|
|
|
|
{
|
2022-12-14 00:16:12 +13:00
|
|
|
$client = new Client($this->queue, $this->connection);
|
|
|
|
|
|
|
|
return $client->enqueue([
|
2022-04-14 00:39:31 +12:00
|
|
|
'project' => $this->project,
|
|
|
|
'domain' => $this->domain,
|
2022-05-17 00:22:06 +12:00
|
|
|
'skipRenewCheck' => $this->skipRenewCheck
|
2022-04-14 00:39:31 +12:00
|
|
|
]);
|
|
|
|
}
|
2022-04-19 04:21:45 +12:00
|
|
|
}
|