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,7 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\PageVisitRequest;
|
||||
use App\Jobs\NotifyTelegramAboutContactMessage;
|
||||
use App\Jobs\NotifyTelegramAboutPageVisit;
|
||||
use App\Jobs\NotifyTelegramAboutPersonaliaClick;
|
||||
use App\Models\Education;
|
||||
use App\Models\Personalia;
|
||||
@@ -58,4 +60,16 @@ class FrontendController extends Controller
|
||||
|
||||
return response()->json(['status' => 'success']);
|
||||
}
|
||||
|
||||
public function pageVisit(PageVisitRequest $request): JsonResponse
|
||||
{
|
||||
NotifyTelegramAboutPageVisit::dispatch(
|
||||
$request->validated(),
|
||||
$request->ip(),
|
||||
$request->userAgent(),
|
||||
$request->header('Accept-Language')
|
||||
);
|
||||
|
||||
return response()->json(['status' => 'queued']);
|
||||
}
|
||||
}
|
||||
|
||||
43
app/Http/Requests/PageVisitRequest.php
Normal file
43
app/Http/Requests/PageVisitRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PageVisitRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'visitor_id' => ['required', 'string', 'max:100'],
|
||||
'url' => ['required', 'url', 'max:2048'],
|
||||
'path' => ['nullable', 'string', 'max:2048'],
|
||||
'title' => ['nullable', 'string', 'max:255'],
|
||||
'referrer' => ['nullable', 'string', 'max:2048'],
|
||||
'language' => ['nullable', 'string', 'max:50'],
|
||||
'timezone' => ['nullable', 'string', 'max:100'],
|
||||
'screen' => ['nullable', 'array'],
|
||||
'screen.width' => ['nullable', 'integer', 'min:0', 'max:100000'],
|
||||
'screen.height' => ['nullable', 'integer', 'min:0', 'max:100000'],
|
||||
'viewport' => ['nullable', 'array'],
|
||||
'viewport.width' => ['nullable', 'integer', 'min:0', 'max:100000'],
|
||||
'viewport.height' => ['nullable', 'integer', 'min:0', 'max:100000'],
|
||||
'device_pixel_ratio' => ['nullable', 'numeric', 'min:0', 'max:100'],
|
||||
'color_depth' => ['nullable', 'integer', 'min:0', 'max:1000'],
|
||||
'platform' => ['nullable', 'string', 'max:255'],
|
||||
'vendor' => ['nullable', 'string', 'max:255'],
|
||||
'hardware_concurrency' => ['nullable', 'integer', 'min:0', 'max:1024'],
|
||||
'device_memory' => ['nullable', 'numeric', 'min:0', 'max:1024'],
|
||||
'cookies_enabled' => ['nullable', 'boolean'],
|
||||
'online' => ['nullable', 'boolean'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user