Add notification action foundation

This commit is contained in:
Eric Peters
2026-04-20 21:59:57 +02:00
parent 8df9622f1b
commit e4762f8e32
22 changed files with 1047 additions and 0 deletions
+2
View File
@@ -16,6 +16,8 @@ class DatabaseSeeder extends Seeder
UserSeeder::class,
UserGitConnectionSeeder::class,
ProjectSeeder::class,
NotificationActionSeeder::class,
NotificationDeliveryLogSeeder::class,
RepositoryConnectionSeeder::class,
BoardColumnSeeder::class,
ProjectTicketMetadataSeeder::class,
@@ -0,0 +1,52 @@
<?php
namespace Database\Seeders;
use App\Enums\NotificationChannel;
use App\Enums\NotificationEventType;
use App\Models\Project;
use Illuminate\Database\Seeder;
class NotificationActionSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$project = Project::query()->where('key', 'CORE')->first()
?? Project::query()->orderBy('id')->first();
if ($project === null) {
return;
}
$project->notificationActions()->updateOrCreate(
[
'name' => 'Core Status Webhook',
],
[
'channel' => NotificationChannel::Webhook,
'channel_configuration' => [],
'delivery_url' => 'https://hooks.example.test/kanbangit/core-status',
'enabled' => true,
'event_type' => NotificationEventType::TicketStatusChanged,
'message_template' => null,
],
);
$project->notificationActions()->updateOrCreate(
[
'name' => 'Core Status Discord',
],
[
'channel' => NotificationChannel::Discord,
'channel_configuration' => [],
'delivery_url' => 'https://discord.com/api/webhooks/123456/core-status',
'enabled' => false,
'event_type' => NotificationEventType::TicketStatusChanged,
'message_template' => '$ticket_key moved from $status_from to $status_to: $url',
],
);
}
}
@@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use App\Models\NotificationAction;
use App\Models\NotificationDeliveryLog;
use Illuminate\Database\Seeder;
class NotificationDeliveryLogSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
$notificationAction = NotificationAction::query()->orderBy('id')->first();
if ($notificationAction === null || $notificationAction->deliveryLogs()->exists()) {
return;
}
NotificationDeliveryLog::factory()
->forNotificationAction($notificationAction)
->succeeded()
->create([
'payload_metadata' => [
'project_key' => 'CORE',
'ticket_key' => 'CORE-1',
],
]);
NotificationDeliveryLog::factory()
->forNotificationAction($notificationAction)
->retryable()
->create([
'payload_metadata' => [
'project_key' => 'CORE',
'ticket_key' => 'CORE-2',
],
]);
}
}