Skip to content

Commit

Permalink
Do not check qts with updates fetched via getDifference
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jun 21, 2019
1 parent eba9257 commit 100d0f8
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/danog/MadelineProto/MTProtoTools/UpdateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,23 +229,25 @@ public function save_update_async($update)
}
}
if ($update['_'] === 'updateNewEncryptedMessage' && !isset($update['message']['decrypted_message'])) {
$cur_state = yield $this->load_update_state_async();
if ($cur_state->qts() === -1) {
$cur_state->qts($update['qts']);
}
if ($update['qts'] < $cur_state->qts()) {
$this->logger->logger('Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state->qts().', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);
if (isset($update['qts'])) {
$cur_state = yield $this->load_update_state_async();
if ($cur_state->qts() === -1) {
$cur_state->qts($update['qts']);
}
if ($update['qts'] < $cur_state->qts()) {
$this->logger->logger('Duplicate update. update qts: '.$update['qts'].' <= current qts '.$cur_state->qts().', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);

return false;
}
if ($update['qts'] > $cur_state->qts() + 1) {
$this->logger->logger('Qts hole. Fetching updates manually: update qts: '.$update['qts'].' > current qts '.$cur_state->qts().'+1, chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);
$this->updaters[false]->resumeDefer();
return false;
}
if ($update['qts'] > $cur_state->qts() + 1) {
$this->logger->logger('Qts hole. Fetching updates manually: update qts: '.$update['qts'].' > current qts '.$cur_state->qts().'+1, chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::ERROR);
$this->updaters[false]->resumeDefer();

return false;
return false;
}
$this->logger->logger('Applying qts: '.$update['qts'].' over current qts '.$cur_state->qts().', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::VERBOSE);
yield $this->method_call_async_read('messages.receivedQueue', ['max_qts' => $cur_state->qts($update['qts'])], ['datacenter' => $this->settings['connection_settings']['default_dc']]);
}
$this->logger->logger('Applying qts: '.$update['qts'].' over current qts '.$cur_state->qts().', chat id: '.$update['message']['chat_id'], \danog\MadelineProto\Logger::VERBOSE);
yield $this->method_call_async_read('messages.receivedQueue', ['max_qts' => $cur_state->qts($update['qts'])], ['datacenter' => $this->settings['connection_settings']['default_dc']]);
yield $this->handle_encrypted_update_async($update);

return;
Expand Down

0 comments on commit 100d0f8

Please sign in to comment.