From 35c0a6bd671f4d44f349298aaca66b48f22e63be Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Tue, 2 May 2017 12:13:01 +0200 Subject: [PATCH] Bugfixes --- src/danog/MadelineProto/MTProtoTools/PeerHandler.php | 1 + src/danog/MadelineProto/MTProtoTools/UpdateHandler.php | 6 ++++-- src/danog/MadelineProto/SecretChats/AuthKeyHandler.php | 4 +++- src/danog/MadelineProto/VoIP/AuthKeyHandler.php | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php index 181caf3e..8a6bfed3 100644 --- a/src/danog/MadelineProto/MTProtoTools/PeerHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/PeerHandler.php @@ -296,6 +296,7 @@ trait PeerHandler switch ($partial['type']) { case 'user': case 'bot': + if (!isset($partial['InputUser'])) throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database'); $full = $this->method_call('users.getFullUser', ['id' => $partial['InputUser']], ['datacenter' => $this->datacenter->curdc]); break; diff --git a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php index 2be8d11e..4d8a32ae 100644 --- a/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/UpdateHandler.php @@ -137,7 +137,9 @@ trait UpdateHandler $this->get_channel_state($channel)['pending_pts_updates'] = []; } try { - $input = $this->get_info('channel#'.$channel)['InputChannel']; + $input = $this->get_info('channel#'.$channel); + if (!isset($input['InputChannel'])) throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database'); + $input = $input['InputChannel']; } catch (\danog\MadelineProto\Exception $e) { return false; } catch (\danog\MadelineProto\RPCErrorException $e) { @@ -611,7 +613,7 @@ trait UpdateHandler curl_setopt($ch, CURLOPT_URL, $this->hook_url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); $parse = parse_url($this->hook_url); if (isset($parse['scheme']) && $parse['scheme'] == 'https') { if (isset($this->pem_path) && file_exists($this->pem_path)) { diff --git a/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php b/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php index 2b4dda3c..d689d744 100644 --- a/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php +++ b/src/danog/MadelineProto/SecretChats/AuthKeyHandler.php @@ -44,7 +44,9 @@ trait AuthKeyHandler public function request_secret_chat($user) { $this->should_serialize = true; - $user = $this->get_info($user)['InputUser']; + $user = $this->get_info($user); + if (!isset($user['InputUser'])) throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database'); + $user = $user['InputUser']; \danog\MadelineProto\Logger::log(['Creating secret chat with '.$user['user_id'].'...'], \danog\MadelineProto\Logger::VERBOSE); $dh_config = $this->get_dh_config(); \danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE); diff --git a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php index 7c102b16..831c391d 100644 --- a/src/danog/MadelineProto/VoIP/AuthKeyHandler.php +++ b/src/danog/MadelineProto/VoIP/AuthKeyHandler.php @@ -29,7 +29,9 @@ trait AuthKeyHandler public function request_call($user) { - $user = $this->get_info($user)['InputUser']; + $user = $this->get_info($user); + if (!isset($user['InputUser'])) throw new \danog\MadelineProto\Exception('This peer is not present in the internal peer database'); + $user = $user['InputUser']; \danog\MadelineProto\Logger::log(['Calling '.$user['user_id'].'...'], \danog\MadelineProto\Logger::VERBOSE); $dh_config = $this->get_dh_config(); \danog\MadelineProto\Logger::log(['Generating a...'], \danog\MadelineProto\Logger::VERBOSE);