Files
services_core/app/Jobs/ProcessNotificationDelivery.php
2026-07-31 13:57:11 +07:00

32 lines
789 B
PHP

<?php
namespace App\Jobs;
use App\Models\NotificationDelivery;
use App\Services\Notification\NotificationManager;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
class ProcessNotificationDelivery implements ShouldQueue
{
use Queueable;
public int $tries = 5;
public function __construct(public int $deliveryId) {}
public function backoff(): array
{
return [60, 300, 900, 3600];
}
public function handle(NotificationManager $manager): void
{
$delivery = NotificationDelivery::find($this->deliveryId);
if (! $delivery || in_array($delivery->status, ['sent', 'delivered', 'read', 'cancelled', 'skipped'], true)) {
return;
}
$manager->deliver($delivery);
}
}