mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge branch 'feature/webhooks' into develop
# Conflicts: # app/Events/UpdatedTransactionGroup.php
This commit is contained in:
commit
8a9a36b512
@ -103,7 +103,9 @@ class StoreController extends Controller
|
||||
throw new ValidationException($validator,0, $e);
|
||||
}
|
||||
app('preferences')->mark();
|
||||
event(new StoredTransactionGroup($transactionGroup, $data['apply_rules'] ?? true));
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
$manager = $this->getManager();
|
||||
/** @var User $admin */
|
||||
|
@ -80,7 +80,9 @@ class UpdateController extends Controller
|
||||
$manager = $this->getManager();
|
||||
|
||||
app('preferences')->mark();
|
||||
event(new UpdatedTransactionGroup($transactionGroup, $data['apply_rules'] ?? true));
|
||||
$applyRules = $data['apply_rules'] ?? true;
|
||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
|
||||
|
||||
/** @var User $admin */
|
||||
$admin = auth()->user();
|
||||
|
@ -57,6 +57,7 @@ class StoreRequest extends FormRequest
|
||||
'group_title' => $this->string('group_title'),
|
||||
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
|
||||
'apply_rules' => $this->boolean('apply_rules', true),
|
||||
'fire_webhooks' => $this->boolean('fire_webhooks', true),
|
||||
'transactions' => $this->getTransactionData(),
|
||||
];
|
||||
// TODO location
|
||||
|
@ -129,6 +129,9 @@ class UpdateRequest extends FormRequest
|
||||
if ($this->has('apply_rules')) {
|
||||
$data['apply_rules'] = $this->boolean('apply_rules', true);
|
||||
}
|
||||
if ($this->has('fire_webhooks')) {
|
||||
$data['fire_webhooks'] = $this->boolean('fire_webhooks', true);
|
||||
}
|
||||
if ($this->has('group_title')) {
|
||||
$data['group_title'] = $this->string('group_title');
|
||||
}
|
||||
|
@ -37,16 +37,19 @@ class StoredTransactionGroup extends Event
|
||||
use SerializesModels;
|
||||
|
||||
public bool $applyRules;
|
||||
public bool $fireWebhooks;
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param TransactionGroup $transactionGroup
|
||||
* @param bool $applyRules
|
||||
*/
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true)
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true, bool $fireWebhooks = true)
|
||||
{
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->fireWebhooks = $fireWebhooks;
|
||||
$this->applyRules = $applyRules;
|
||||
}
|
||||
}
|
||||
|
@ -36,10 +36,9 @@ class UpdatedTransactionGroup extends Event
|
||||
{
|
||||
use SerializesModels;
|
||||
|
||||
/** @var bool */
|
||||
public $applyRules;
|
||||
/** @var TransactionGroup The group that was stored. */
|
||||
public $transactionGroup;
|
||||
public bool $applyRules;
|
||||
public bool $fireWebhooks;
|
||||
public TransactionGroup $transactionGroup;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
@ -47,9 +46,10 @@ class UpdatedTransactionGroup extends Event
|
||||
* @param TransactionGroup $transactionGroup
|
||||
* @param bool $applyRules
|
||||
*/
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true)
|
||||
public function __construct(TransactionGroup $transactionGroup, bool $applyRules = true, bool $fireWebhooks = true)
|
||||
{
|
||||
$this->transactionGroup = $transactionGroup;
|
||||
$this->fireWebhooks = $fireWebhooks;
|
||||
$this->applyRules = $applyRules;
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,13 @@ class StoredGroupEventHandler
|
||||
{
|
||||
Log::debug(__METHOD__);
|
||||
$group = $storedGroupEvent->transactionGroup;
|
||||
$user = $group->user;
|
||||
if (false === $storedGroupEvent->fireWebhooks) {
|
||||
Log::info(sprintf('Will not fire webhooks for transaction group #%d', $group->id));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user = $group->user;
|
||||
/** @var MessageGeneratorInterface $engine */
|
||||
$engine = app(MessageGeneratorInterface::class);
|
||||
$engine->setUser($user);
|
||||
|
@ -82,9 +82,14 @@ class UpdatedGroupEventHandler
|
||||
*/
|
||||
public function triggerWebhooks(UpdatedTransactionGroup $updatedGroupEvent): void
|
||||
{
|
||||
Log::debug('UpdatedGroupEventHandler:triggerWebhooks');
|
||||
Log::debug(__METHOD__);
|
||||
$group = $updatedGroupEvent->transactionGroup;
|
||||
$user = $group->user;
|
||||
if (false === $updatedGroupEvent->fireWebhooks) {
|
||||
Log::info(sprintf('Will not fire webhooks for transaction group #%d', $group->id));
|
||||
|
||||
return;
|
||||
}
|
||||
$user = $group->user;
|
||||
/** @var MessageGeneratorInterface $engine */
|
||||
$engine = app(MessageGeneratorInterface::class);
|
||||
$engine->setUser($user);
|
||||
|
@ -70,7 +70,7 @@ class CreateController extends Controller
|
||||
$newGroup = $service->cloneGroup($group);
|
||||
|
||||
// event!
|
||||
event(new StoredTransactionGroup($newGroup, true));
|
||||
event(new StoredTransactionGroup($newGroup));
|
||||
|
||||
app('preferences')->mark();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user