coolify/app/Jobs/SendMessageToDiscordJob.php

47 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
2023-09-14 10:12:44 +02:00
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;
2024-06-10 22:43:34 +02:00
class SendMessageToDiscordJob implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 5;
2024-06-10 22:43:34 +02:00
public $backoff = 10;
/**
* The maximum number of unhandled exceptions to allow before failing.
*/
public int $maxExceptions = 5;
public function __construct(
public string $text,
public string $webhookUrl
2024-06-19 08:59:46 +02:00
) {}
/**
* Execute the job.
*/
public function handle(): void
{
$payload = [
'content' => $this->text,
];
Http::post($this->webhookUrl, $payload);
}
}