Clear up webhooks

This commit is contained in:
James Cole
2023-01-05 19:05:23 +01:00
parent 7bd824e8cb
commit 1fee2092d6
17 changed files with 219 additions and 115 deletions

View File

@@ -46,6 +46,12 @@ interface MessageGeneratorInterface
*/
public function setObjects(Collection $objects): void;
/**
* @param Collection $webhooks
* @return void
*/
public function setWebhooks(Collection $webhooks): void;
/**
* @param int $trigger
*/

View File

@@ -53,6 +53,15 @@ class StandardMessageGenerator implements MessageGeneratorInterface
private int $version = 0;
private Collection $webhooks;
/**
*
*/
public function __construct()
{
$this->objects = new Collection();
$this->webhooks = new Collection();
}
/**
*
*/
@@ -60,7 +69,9 @@ class StandardMessageGenerator implements MessageGeneratorInterface
{
Log::debug(__METHOD__);
// get the webhooks:
$this->webhooks = $this->getWebhooks();
if (0 === $this->webhooks->count()) {
$this->webhooks = $this->getWebhooks();
}
// do some debugging
Log::debug(
@@ -129,7 +140,9 @@ class StandardMessageGenerator implements MessageGeneratorInterface
switch ($class) {
default:
// Line is ignored because all of Firefly III's Models have an id property.
Log::error(sprintf('Webhook #%d was given %s#%d to deal with but can\'t extract user ID from it.', $webhook->id, $class, $model->id)); // @phpstan-ignore-line
Log::error(
sprintf('Webhook #%d was given %s#%d to deal with but can\'t extract user ID from it.', $webhook->id, $class, $model->id)
); // @phpstan-ignore-line
return;
case TransactionGroup::class:
@@ -240,4 +253,12 @@ class StandardMessageGenerator implements MessageGeneratorInterface
{
$this->user = $user;
}
/**
* @inheritDoc
*/
public function setWebhooks(Collection $webhooks): void
{
$this->webhooks = $webhooks;
}
}