fix: infinity scroll, init data in base64
This commit is contained in:
@@ -19,7 +19,7 @@ class SignatureValidator
|
||||
return;
|
||||
}
|
||||
|
||||
$initDataString = rawurldecode($request->header('X-Telegram-Initdata'));
|
||||
$initDataString = base64_decode($request->header('X-Telegram-Initdata'));
|
||||
|
||||
if (! $initDataString) {
|
||||
throw new TelegramInvalidSignatureException('Invalid Telegram signature!');
|
||||
@@ -78,13 +78,4 @@ class SignatureValidator
|
||||
|
||||
return implode(PHP_EOL, $array);
|
||||
}
|
||||
|
||||
public function ensureUserWantsToReceiveMessages($request): void
|
||||
{
|
||||
$initDataString = rawurldecode($request->header('X-Telegram-Initdata'));
|
||||
|
||||
if (! $initDataString) {
|
||||
throw new TelegramInvalidSignatureException('Invalid Telegram signature!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
namespace Openguru\OpenCartFramework\Telegram;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use JsonException;
|
||||
use Openguru\OpenCartFramework\Application;
|
||||
use Openguru\OpenCartFramework\Http\Request;
|
||||
use Openguru\OpenCartFramework\Logger\Logger;
|
||||
|
||||
class TelegramService
|
||||
@@ -68,29 +65,4 @@ class TelegramService
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function ensureUserWantsToReceiveMessages(): bool
|
||||
{
|
||||
/** @var Request $request */
|
||||
$request = Application::getInstance()->get(Request::class);
|
||||
|
||||
$initDataString = $request->header('X-Telegram-Initdata');
|
||||
|
||||
if (! $initDataString) {
|
||||
return false;
|
||||
}
|
||||
|
||||
parse_str($initDataString, $initData);
|
||||
if (! isset($initData['user'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$user = json_decode($initData['user'], true, 512, JSON_THROW_ON_ERROR);
|
||||
return ! empty($user['allows_write_to_pm']);
|
||||
} catch (JsonException $e) {
|
||||
$this->logger->logException($e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user