Add page visit Telegram notifications
Some checks failed
Tests / Laravel tests (pull_request) Failing after 6m57s

This commit is contained in:
2026-06-03 23:19:06 +02:00
parent fdc10a0acb
commit bbfc64031f
10 changed files with 434 additions and 45 deletions

View File

@@ -3,12 +3,12 @@
namespace App\Jobs;
use App\Models\Personalia;
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 NotifyTelegramAboutPersonaliaClick implements ShouldQueue
{
@@ -27,25 +27,8 @@ class NotifyTelegramAboutPersonaliaClick implements ShouldQueue
$this->userAgent = $userAgent;
}
public function handle(): void
public function handle(TelegramNotificationService $telegram): 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',
]);
$telegram->notifyPersonaliaClick($this->personalia, $this->ip, $this->userAgent);
}
}