Add ticket create notification event support
This commit is contained in:
@@ -2,17 +2,21 @@
|
||||
|
||||
namespace App\Actions\Tickets;
|
||||
|
||||
use App\Actions\Notifications\BuildTicketCreatedPayload;
|
||||
use App\Actions\Notifications\TicketCreated;
|
||||
use App\Enums\TicketWorklogEntryType;
|
||||
use App\Models\Project;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketStatus;
|
||||
use App\Models\User;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateProjectTicket
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BuildTicketCreatedPayload $buildTicketCreatedPayload,
|
||||
private readonly CreateTicketWorklogEntry $createTicketWorklogEntry,
|
||||
) {}
|
||||
|
||||
@@ -53,6 +57,8 @@ class CreateProjectTicket
|
||||
'story_points' => Arr::get($attributes, 'story_points'),
|
||||
]);
|
||||
|
||||
$occurredAt = CarbonImmutable::now();
|
||||
|
||||
if ($actor !== null) {
|
||||
$this->createTicketWorklogEntry->handle(
|
||||
$ticket,
|
||||
@@ -69,6 +75,16 @@ class CreateProjectTicket
|
||||
);
|
||||
}
|
||||
|
||||
TicketCreated::dispatch(
|
||||
$this->buildTicketCreatedPayload->handle(
|
||||
$project,
|
||||
$ticket,
|
||||
$ticketStatus,
|
||||
$actor,
|
||||
$occurredAt,
|
||||
),
|
||||
);
|
||||
|
||||
return $ticket;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user