2020-12-05 00:01:26 -06:00
|
|
|
<?php
|
2021-01-29 11:50:35 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* SendWebhookMessage.php
|
|
|
|
* Copyright (c) 2021 james@firefly-iii.org
|
|
|
|
*
|
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-12-21 22:35:06 -06:00
|
|
|
declare(strict_types=1);
|
2020-12-05 00:01:26 -06:00
|
|
|
|
|
|
|
namespace FireflyIII\Jobs;
|
|
|
|
|
|
|
|
use FireflyIII\Models\WebhookMessage;
|
|
|
|
use FireflyIII\Services\Webhook\WebhookSenderInterface;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
2023-04-01 00:04:42 -05:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2020-12-05 00:01:26 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class SendWebhookMessage
|
|
|
|
*/
|
|
|
|
class SendWebhookMessage implements ShouldQueue
|
|
|
|
{
|
2022-10-30 08:24:28 -05:00
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
2020-12-05 00:01:26 -06:00
|
|
|
|
2021-03-21 03:15:40 -05:00
|
|
|
private WebhookMessage $message;
|
2020-12-05 00:01:26 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new job instance.
|
|
|
|
*
|
2022-12-29 12:42:26 -06:00
|
|
|
* @param WebhookMessage $message
|
2020-12-05 00:01:26 -06:00
|
|
|
*/
|
|
|
|
public function __construct(WebhookMessage $message)
|
|
|
|
{
|
|
|
|
$this->message = $message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the job.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function handle(): void
|
|
|
|
{
|
2021-11-19 08:47:19 -06:00
|
|
|
Log::debug(sprintf('Now handling webhook message #%d', $this->message->id));
|
2020-12-05 00:01:26 -06:00
|
|
|
// send job!
|
|
|
|
$sender = app(WebhookSenderInterface::class);
|
|
|
|
$sender->setMessage($this->message);
|
|
|
|
$sender->send();
|
|
|
|
}
|
|
|
|
}
|