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