Apply fixes from StyleCI

This commit is contained in:
Daniil Gentili 2017-04-02 14:43:47 +00:00 committed by StyleCI Bot
parent 4d8ed0582e
commit d41b58827e
4 changed files with 20 additions and 8 deletions

View File

@ -282,7 +282,7 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
],
'calls' => [
'accept_calls' => true, // Should I accept calls? Can be true, false or on array of user ids from which to accept calls
'allow_p2p' => false // Should I accept p2p calls?
'allow_p2p' => false, // Should I accept p2p calls?
],
'threading' => [
'allow_threading' => false, // Should I use threading, if it is enabled?

View File

@ -497,6 +497,7 @@ trait UpdateHandler
return $this->accept_call($update['phone_call']);
case 'phoneCallAccepted':
$this->confirm_call($update['phone_call']);
return;
case 'phoneCall':
$this->complete_call($update['phone_call']);
@ -561,10 +562,10 @@ trait UpdateHandler
\danog\MadelineProto\Logger::log(['Completing creation of secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE);
$this->complete_secret_chat($update['chat']);
return;
}
//\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::NOTICE);
}
if (!$this->settings['updates']['handle_updates']) {
return;

View File

@ -212,5 +212,9 @@ trait AuthKeyHandler
return 0;
}
public function get_secret_chat($chat) { return $this->secret_chats[$chat]; }
public function get_secret_chat($chat)
{
return $this->secret_chats[$chat];
}
}

View File

@ -48,8 +48,12 @@ trait AuthKeyHandler
public function accept_call($params)
{
if ($this->settings['calls']['accept_calls'] === false) return false;
if (is_array($this->settings['calls']['accept_calls']) && !in_array($this->settings['calls']['accept_calls'])) return false;
if ($this->settings['calls']['accept_calls'] === false) {
return false;
}
if (is_array($this->settings['calls']['accept_calls']) && !in_array($this->settings['calls']['accept_calls'])) {
return false;
}
if ($params['protocol']['udp_p2p'] && !$this->settings['calls']['allow_p2p']) {
return false;
}
@ -63,6 +67,7 @@ trait AuthKeyHandler
$this->handle_pending_updates();
$this->get_updates_difference();
}
public function confirm_call($params)
{
if ($this->call_status($params['id']) !== $this->REQUESTED) {
@ -79,13 +84,15 @@ trait AuthKeyHandler
$key['visualization'] = '';
$length = new \phpseclib\Math\BigInteger(count($this->emojis));
foreach (str_split(strrev(substr(hash('sha256', $this->calls[$params['id']]['g_a']->toBytes().$key['auth_key'], true), 20)), 8) as $number) {
$key['visualization'] .= $this->emojis[(int)((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
$key['visualization'] .= $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
}
$this->calls[$params['id']] = ['status' => $this->READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => $this->settings['tl_scheme']['layer'], 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol']];
$this->handle_pending_updates();
}
public function complete_call($params) {
public function complete_call($params)
{
if ($this->call_status($params['id']) !== $this->ACCEPTED) {
\danog\MadelineProto\Logger::log(['Could not find and confirm call '.$params['id']]);
@ -105,7 +112,7 @@ trait AuthKeyHandler
$key['visualization'] = '';
$length = new \phpseclib\Math\BigInteger(count($this->emojis));
foreach (str_split(strrev(substr(hash('sha256', $params['g_a_or_b']->toBytes().$key['auth_key'], true), 20)), 8) as $number) {
$key['visualization'] .= $this->emojis[(int)((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
$key['visualization'] .= $this->emojis[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
}
$this->calls[$params['id']] = ['status' => $this->READY, 'key' => $key, 'admin' => false, 'user_id' => $params['admin_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 1, 'out_seq_no_x' => 0, 'layer' => $this->settings['tl_scheme']['layer'], 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol']];