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

@@ -42,6 +42,7 @@ class JournalDestroyService
*/
public function destroy(TransactionJournal $journal): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
/** @var Transaction $transaction */
foreach ($journal->transactions()->get() as $transaction) {
Log::debug(sprintf('Will now delete transaction #%d', $transaction->id));

View File

@@ -25,6 +25,7 @@ namespace FireflyIII\Services\Internal\Destroy;
use FireflyIII\Events\DestroyedTransactionGroup;
use FireflyIII\Models\TransactionGroup;
use Illuminate\Support\Facades\Log;
/**
* Class TransactionGroupDestroyService
@@ -38,6 +39,7 @@ class TransactionGroupDestroyService
*/
public function destroy(TransactionGroup $transactionGroup): void
{
Log::debug(sprintf('Now in %s', __METHOD__));
/** @var JournalDestroyService $service */
$service = app(JournalDestroyService::class);
foreach ($transactionGroup->transactionJournals as $journal) {

View File

@@ -56,7 +56,8 @@ class StandardWebhookSender implements WebhookSenderInterface
// have the signature generator generate a signature. If it fails, the error thrown will
// end up in send() to be caught.
$signatureGenerator = app(SignatureGeneratorInterface::class);
$this->message->sent = true;
$this->message->save();
try {
$signature = $signatureGenerator->generate($this->message);
} catch (FireflyException $e) {
@@ -108,7 +109,6 @@ class StandardWebhookSender implements WebhookSenderInterface
$client = new Client();
try {
$res = $client->request('POST', $this->message->webhook->url, $options);
$this->message->sent = true;
} catch (RequestException $e) {
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
@@ -127,6 +127,7 @@ class StandardWebhookSender implements WebhookSenderInterface
return;
}
$this->message->sent = true;
$this->message->save();
Log::debug(sprintf('Webhook message #%d was sent. Status code %d', $this->message->id, $res->getStatusCode()));