File size: 1,374 Bytes
89a1081 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | <?php
namespace App\Jobs;
use App\Enums\CommunicationStatusEnum;
use App\Enums\StatusEnum;
use App\Http\Utility\SendWhatsapp;
use App\Models\CommunicationLog;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\WhatsappLog;
use Exception;
class ProcessWhatsapp implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(protected CommunicationLog $whatsappLog){}
/**
* Execute the job.
*
* @return void
*/
public function handle(): void
{
try {
$whatsappLog = $this->whatsappLog;
if($whatsappLog->whatsappGateway->type == StatusEnum::FALSE->status() && $whatsappLog->status != CommunicationStatusEnum::FAIL->value) {
SendWhatsapp::sendNodeMessages($whatsappLog, null);
} else {
SendWhatsapp::sendCloudApiMessages($whatsappLog, null);
}
} catch (\Exception $exception) {
\Log::error("Process whatsapp failed: " . $exception->getMessage());
}
}
}
|