Add page visit Telegram notifications
Some checks failed
Tests / Laravel tests (pull_request) Failing after 6m57s
Some checks failed
Tests / Laravel tests (pull_request) Failing after 6m57s
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\TelegramNotificationService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class NotifyTelegramAboutContactMessage implements ShouldQueue
|
||||
{
|
||||
@@ -35,30 +35,15 @@ class NotifyTelegramAboutContactMessage implements ShouldQueue
|
||||
$this->phone = $phone;
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
public function handle(TelegramNotificationService $telegram): void
|
||||
{
|
||||
$email = $this->email ?? '–';
|
||||
$phone = $this->phone ?? '–';
|
||||
|
||||
$text = <<<TEXT
|
||||
📩 *Nieuw contactbericht ontvangen*
|
||||
|
||||
👤 Naam: *{$this->name}*
|
||||
|
||||
💬 Bericht:
|
||||
{$this->message}
|
||||
📧 Email: {$email}
|
||||
📱 Telefoon: {$phone}
|
||||
🌐 IP: {$this->ip}
|
||||
🧭 User Agent: `{$this->userAgent}`
|
||||
|
||||
🕒 Tijdstip: *{now()->format('d-m-Y H:i')}*
|
||||
TEXT;
|
||||
|
||||
Http::post('https://api.telegram.org/bot'.config('services.telegram.bot_token').'/sendMessage', [
|
||||
'chat_id' => config('services.telegram.chat_id'),
|
||||
'text' => $text,
|
||||
'parse_mode' => 'Markdown',
|
||||
]);
|
||||
$telegram->notifyContactMessage(
|
||||
$this->name,
|
||||
$this->message,
|
||||
$this->ip,
|
||||
$this->userAgent,
|
||||
$this->email,
|
||||
$this->phone
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user