Files
coruna-lab/server/app/Telegram/Middleware/AuthorizedChat.php
T
2026-08-07 05:21:44 +08:00

24 lines
483 B
PHP

<?php
namespace App\Telegram\Middleware;
use SergiX44\Nutgram\Nutgram;
class AuthorizedChat
{
public function __invoke(Nutgram $bot, callable $next): mixed
{
$expected = (string) config('coruna.telegram.owner_chat_id', '');
if ($expected === '') {
return null;
}
$chatId = $bot->chatId();
if ($chatId === null || (string) $chatId !== $expected) {
return null;
}
return $next($bot);
}
}