Giant Update
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\NotificationBroadcast;
|
||||
use App\Services\Notification\NotificationService;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class ProcessBroadcast implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public function __construct(public int $broadcastId) {}
|
||||
|
||||
public function handle(NotificationService $service): void
|
||||
{
|
||||
$broadcast = NotificationBroadcast::with(['tenant', 'template', 'channelConfig'])->find($this->broadcastId);
|
||||
if ($broadcast) {
|
||||
$service->processBroadcast($broadcast);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user