From 10d7b3b40bf83ac69d89990bac02569a4ba61aa3 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 14 Sep 2016 19:37:54 +0000 Subject: [PATCH] Applied fixes from StyleCI --- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 8 ++++---- .../MadelineProto/MTProtoTools/MessageHandler.php | 1 + .../MadelineProto/MTProtoTools/ResponseHandler.php | 4 +++- src/danog/MadelineProto/MTProtoTools/SaltHandler.php | 10 ++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index 57758856..85a559ad 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -22,11 +22,11 @@ class CallHandler extends AuthKeyHandler $response = null; $count = 0; while ($response == null && $count++ < $this->settings['max_tries']['response']) { - $this->log->log("Getting response...."); + $this->log->log('Getting response....'); $deserialized = $this->recv_message(); end($this->incoming_messages); $tempres = $this->handle_message($deserialized, $last_sent, key($this->incoming_messages)); -var_dump($this->incoming_messages); + var_dump($this->incoming_messages); if (isset($this->outgoing_messages[$last_sent]['response']) && isset($this->incoming_messages[$this->outgoing_messages[$last_sent]['response']]['content'])) { $response = $this->incoming_messages[$this->outgoing_messages[$last_sent]['response']]['content']; } @@ -49,7 +49,7 @@ var_dump($this->incoming_messages); foreach (range(1, $this->settings['max_tries']['query']) as $i) { try { $int_message_id = $this->send_message($this->tl->serialize_method($method, $args), $this->tl->content_related($method)); - $this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args ]; + $this->outgoing_messages[$int_message_id]['content'] = ['method' => $method, 'args' => $args]; $server_answer = $this->wait_for_response($int_message_id); } catch (Exception $e) { $this->log->log('An error occurred while calling method '.$method.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().'. Recreating connection and retrying to call method...'); @@ -71,7 +71,7 @@ var_dump($this->incoming_messages); foreach (range(1, $this->settings['max_tries']['query']) as $i) { try { $int_message_id = $this->send_message($this->tl->serialize_obj($object, $args), $this->tl->content_related($object)); - $this->outgoing_messages[$int_message_id]['content'] = ['object' => $object, 'args' => $args ]; + $this->outgoing_messages[$int_message_id]['content'] = ['object' => $object, 'args' => $args]; // $server_answer = $this->wait_for_response($int_message_id); } catch (Exception $e) { $this->log->log('An error occurred while calling object '.$object.': '.$e->getMessage().' in '.$e->getFile().':'.$e->getLine().'. Recreating connection and retrying to call object...'); diff --git a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php index 1a180722..41935c03 100644 --- a/src/danog/MadelineProto/MTProtoTools/MessageHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/MessageHandler.php @@ -106,6 +106,7 @@ class MessageHandler extends Crypt } $deserialized = $this->tl->deserialize(\danog\MadelineProto\Tools::fopen_and_write('php://memory', 'rw+b', $message_data)); $this->incoming_messages[$message_id]['content'] = $deserialized; + return $deserialized; } } diff --git a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php index 2f4a99b7..944d23e0 100644 --- a/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/ResponseHandler.php @@ -84,8 +84,9 @@ class ResponseHandler extends MsgIdHandler return end($responses); break; default: - $this->log->log("Received multiple responses, returning last one"); + $this->log->log('Received multiple responses, returning last one'); $this->log->log($responses); + return end($responses); break; } @@ -96,6 +97,7 @@ class ResponseHandler extends MsgIdHandler $this->ack_incoming_message_id($response['orig_message']['msg_id']); // Acknowledge that I received the server's response } else { $this->check_message_id($message['orig_message']['msg_id'], false); + return $this->handle_message($response['orig_message']); } break; diff --git a/src/danog/MadelineProto/MTProtoTools/SaltHandler.php b/src/danog/MadelineProto/MTProtoTools/SaltHandler.php index 6876fb9f..fdca3f48 100644 --- a/src/danog/MadelineProto/MTProtoTools/SaltHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/SaltHandler.php @@ -20,12 +20,14 @@ class SaltHandler extends ResponseHandler public function add_salts($salts) { foreach ($salts as $salt) { - $this->addsalt($salt["valid_since"], $salt["valid_until"], $salt["salt"]); + $this->addsalt($salt['valid_since'], $salt['valid_until'], $salt['salt']); } } - public function addsalt($valid_since, $valid_until, $salt) { - if (!isset($this->settings["authorization"]["temp_auth_key"]["salts"][$salt])) { - $settings["authorization"]["temp_auth_key"]["salts"][$salt] = [ "valid_since" => $valid_since, "valid_until" => $valid_until ]; + + public function addsalt($valid_since, $valid_until, $salt) + { + if (!isset($this->settings['authorization']['temp_auth_key']['salts'][$salt])) { + $settings['authorization']['temp_auth_key']['salts'][$salt] = ['valid_since' => $valid_since, 'valid_until' => $valid_until]; } } }