1
0
Fork 0
mirror of synced 2024-09-30 17:26:48 +13:00
appwrite/src/Appwrite/Event/Certificate.php

82 lines
1.8 KiB
PHP
Raw Normal View History

<?php
namespace Appwrite\Event;
use Utopia\Database\Document;
2022-12-14 00:16:12 +13:00
use Utopia\Queue\Client;
use Utopia\Queue\Connection;
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-12-14 00:16:12 +13:00
public function __construct(protected Connection $connection)
{
2022-12-21 01:22:58 +13:00
parent::__construct(Event::CERTIFICATES_QUEUE_NAME, Event::CERTIFICATES_CLASS_NAME, $connection);
}
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
*/
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
*/
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-05-12 05:05:43 +12:00
$this->skipRenewCheck = $skipRenewCheck;
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-05-12 05:05:43 +12:00
return $this->skipRenewCheck;
}
2022-04-19 04:21:45 +12:00
/**
* Executes the event and sends it to the certificates worker.
*
* @return string|bool
* @throws \InvalidArgumentException
*/
public function trigger(): string|bool
{
2022-12-14 00:16:12 +13:00
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'project' => $this->project,
'domain' => $this->domain,
2022-05-17 00:22:06 +12:00
'skipRenewCheck' => $this->skipRenewCheck
]);
}
2022-04-19 04:21:45 +12:00
}