type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-08 12:51:31 +02:00
parent f5a709fd56
commit b150d84932
3 changed files with 29 additions and 1 deletions

View File

@@ -48,10 +48,19 @@ use Espo\Entities\{
*/
class Manager
{
/**
* @var string
*/
private $cacheKey = 'webhooks';
/**
* @var string[]
*/
protected $skipAttributeList = ['isFollowed', 'modifiedAt', 'modifiedBy'];
/**
* @var ?array<string,bool>
*/
private $data = null;
private $config;
@@ -102,6 +111,9 @@ class Manager
$this->dataCache->store($this->cacheKey, $this->data);
}
/**
* @return array<string,bool>
*/
private function buildData(): array
{
$data = [];

View File

@@ -248,6 +248,9 @@ class Queue
$this->send($webhook, $dataList, $actualItemList);
}
/**
* @param string[] $forbiddenAttributeList
*/
private function prepareItemData(WebhookQueueItem $item, ?User $user, array $forbiddenAttributeList): ?stdClass
{
$targetType = $item->get('targetType');
@@ -285,6 +288,10 @@ class Queue
return $data;
}
/**
* @param mixed[] $dataList
* @param WebhookQueueItem[] $itemList
*/
private function send(Webhook $webhook, array $dataList, array $itemList): void
{
try {
@@ -324,6 +331,9 @@ class Queue
$this->log->debug("Webhook Queue: Webhook '" . $webhook->getId() . "' sent, response code: {$code}.");
}
/**
* @param WebhookQueueItem[] $itemList
*/
protected function failQueueItemList(array $itemList, bool $force = false): void
{
foreach ($itemList as $item) {
@@ -331,6 +341,9 @@ class Queue
}
}
/**
* @param WebhookQueueItem[] $itemList
*/
protected function succeedQueueItemList(array $itemList): void
{
foreach ($itemList as $item) {

View File

@@ -44,13 +44,16 @@ class Sender
private const TIMEOUT = 10;
private $config;
private Config $config;
public function __construct(Config $config)
{
$this->config = $config;
}
/**
* @param array<int,mixed> $dataList
*/
public function send(Webhook $webhook, array $dataList): int
{
$payload = json_encode($dataList);