@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\InterestRequest;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class NotifyInterestReceived implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
public int $timeout = 30;
|
||||
|
||||
public function __construct(public int $interestId, public string $recipient) {}
|
||||
|
||||
/** @return list<int> */
|
||||
public function backoff(): array
|
||||
{
|
||||
return [60, 300, 900];
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (! config('portal.notifications_enabled') || ! in_array($this->recipient, config('portal.notification_recipients'), true)) {
|
||||
return;
|
||||
}
|
||||
$interest = InterestRequest::find($this->interestId);
|
||||
if (! $interest) {
|
||||
return;
|
||||
}
|
||||
$body = "Foi recebida uma manifestação de interesse: {$interest->reference}.\n\nConsulte o pedido na área protegida:\n".url('/management/interests/'.$interest->id);
|
||||
Mail::raw($body, fn ($message) => $message->to($this->recipient)->subject('Novo pedido de interesse — '.$interest->reference));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user