All checks were successful
Tests / Laravel tests (pull_request) Successful in 2m36s
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace App\Jobs;
|
||
|
||
use App\Models\Personalia;
|
||
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 NotifyTelegramAboutPersonaliaClick implements ShouldQueue
|
||
{
|
||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||
|
||
protected Personalia $personalia;
|
||
|
||
protected ?string $ip;
|
||
|
||
protected ?string $userAgent;
|
||
|
||
public function __construct(Personalia $personalia, ?string $ip, ?string $userAgent)
|
||
{
|
||
$this->personalia = $personalia;
|
||
$this->ip = $ip;
|
||
$this->userAgent = $userAgent;
|
||
}
|
||
|
||
public function handle(): void
|
||
{
|
||
$ip = $this->ip ?? '–';
|
||
$userAgent = $this->userAgent ?? '–';
|
||
|
||
$message = <<<TEXT
|
||
👤 *Persoonlijke gegevens bekeken*
|
||
|
||
Naam: {$this->personalia->value}
|
||
IP: {$ip}
|
||
User Agent: `{$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' => $message,
|
||
'parse_mode' => 'Markdown',
|
||
]);
|
||
}
|
||
}
|