Fixes to update handler and calls

This commit is contained in:
Daniil Gentili 2017-09-17 16:58:57 +00:00
parent 980a7fef27
commit 7e7409e549
3 changed files with 3 additions and 4 deletions

View File

@ -37,7 +37,6 @@ if (getenv('TEST_SECRET_CHAT') == '') {
echo 'Loading settings...'.PHP_EOL;
$settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: [];
var_dump($settings);
if ($MadelineProto === false) {
echo 'Loading MadelineProto...'.PHP_EOL;
$MadelineProto = new \danog\MadelineProto\API($settings);

View File

@ -575,7 +575,7 @@ trait UpdateHandler
$update['message']['out'] = true;
}
\danog\MadelineProto\Logger::log(['Saving an update of type '.$update['_'].'...'], \danog\MadelineProto\Logger::VERBOSE);
if (isset($this->settings['pwr']['strict']) && $this->settings['pwr']['strict']) {
if (isset($this->settings['pwr']['strict']) && $this->settings['pwr']['strict'] && isset($this->settings['pwr']['update_handler'])) {
$this->pwr_update_handler($update);
} else {
in_array($this->settings['updates']['callback'], [['danog\MadelineProto\API', 'get_updates_update_handler'], 'get_updates_update_handler']) ? $this->get_updates_update_handler($update) : $this->settings['updates']['callback']($update);

View File

@ -89,7 +89,7 @@ trait AuthKeyHandler
}
if ($e->rpc === 'CALL_ALREADY_DECLINED') {
\danog\MadelineProto\Logger::log(['Call '.$call['id'].' already declined']);
$this->discard_cal($call['id']);
$this->discard_call($call['id']);
//$this->calls[$call['id']]->discard();
return false;
@ -263,7 +263,7 @@ trait AuthKeyHandler
try {
$res = $this->method_call('phone.discardCall', ['peer' => $call, 'duration' => time() - $this->calls[$call['id']]->whenCreated(), 'connection_id' => $this->calls[$call['id']]->getPreferredRelayID(), 'reason' => $reason], ['datacenter' => $this->datacenter->curdc]);
} catch (\danog\MadelineProto\RPCErrorException $e) {
if ($e->rpc !== 'CALL_ALREADY_DECLINED') {
if (!in_array($e->rpc, ['CALL_ALREADY_DECLINED', 'CALL_ALREADY_ACCEPTED'])) {
throw $e;
}
}