Fixes and improvements

This commit is contained in:
Daniil Gentili 2019-06-02 12:29:29 +02:00
parent 9317a9feed
commit 751aedf92b
5 changed files with 64 additions and 61 deletions

View File

@ -17,7 +17,8 @@
* 2fa+++++ * 2fa+++++
* improved callfork * improved callfork
* split acks * split acks
* TL callabck
* channel state
Things to expect in the next releases: Things to expect in the next releases:
Document async apis Document async apis
optional max_id and min_id optional max_id and min_id

View File

@ -58,7 +58,8 @@ class CheckLoop extends ResumableSignalLoop
if ($connection->hasPendingCalls()) { if ($connection->hasPendingCalls()) {
$last_recv = $connection->get_max_id(true); $last_recv = $connection->get_max_id(true);
if ($connection->temp_auth_key !== null) { if ($connection->temp_auth_key !== null) {
$message_ids = $connection->getPendingCalls(); //array_values($connection->new_outgoing); $full_message_ids = $connection->getPendingCalls(); //array_values($connection->new_outgoing);
foreach (array_chunk($full_message_ids, 8192) as $message_ids) {
$deferred = new Deferred(); $deferred = new Deferred();
$deferred->promise()->onResolve( $deferred->promise()->onResolve(
function ($e, $result) use ($message_ids, $API, $connection, $datacenter) { function ($e, $result) use ($message_ids, $API, $connection, $datacenter) {
@ -121,6 +122,7 @@ class CheckLoop extends ResumableSignalLoop
} }
$API->logger->logger("Still missing $list on DC $datacenter, sending state request", \danog\MadelineProto\Logger::ERROR); $API->logger->logger("Still missing $list on DC $datacenter, sending state request", \danog\MadelineProto\Logger::ERROR);
yield $API->object_call_async('msgs_state_req', ['msg_ids' => $message_ids], ['datacenter' => $datacenter, 'promise' => $deferred]); yield $API->object_call_async('msgs_state_req', ['msg_ids' => $message_ids], ['datacenter' => $datacenter, 'promise' => $deferred]);
}
} else { } else {
foreach ($connection->new_outgoing as $message_id) { foreach ($connection->new_outgoing as $message_id) {
if (isset($connection->outgoing_messages[$message_id]['sent']) if (isset($connection->outgoing_messages[$message_id]['sent'])

View File

@ -404,7 +404,7 @@ class MTProto extends AsyncConstruct implements TLCallback
} }
if (!$this->settings['updates']['handle_old_updates']) { if (!$this->settings['updates']['handle_old_updates']) {
$this->channels_state = new CombinedUpdatesState([false => new UpdatesState()]); $this->channels_state = new CombinedUpdatesState();
$this->got_state = false; $this->got_state = false;
} }
yield $this->connect_to_all_dcs_async(); yield $this->connect_to_all_dcs_async();

View File

@ -27,10 +27,10 @@ class CombinedUpdatesState
private $states = []; private $states = [];
public function __construct($init = []) public function __construct($init = [])
{ {
$this->states[false] = new UpdatesState();
if (!is_array($init)) { if (!is_array($init)) {
return; return;
} }
$this->states[false] = new UpdatesState();
foreach ($init as $channel => $state) { foreach ($init as $channel => $state) {
if (is_array($state)) { if (is_array($state)) {
$state = new UpdatesState($state, $channel); $state = new UpdatesState($state, $channel);

View File

@ -73,7 +73,7 @@ trait ApiTemplates
<li>Click on create application</li> <li>Click on create application</li>
</ol>', '<input type="string" name="api_id" placeholder="API ID" required/><input type="string" name="api_hash" placeholder="API hash" required/>')); </ol>', '<input type="string" name="api_id" placeholder="API ID" required/><input type="string" name="api_hash" placeholder="API hash" required/>'));
} else { } else {
yield $stdout->write($this->web_api_echo_template('Enter your phone number<br><b>'.$message.'</b>', '<input type="text" name="phone_number" placeholder="Phone number" required/>')); yield $stdout->write($this->web_api_echo_template('Enter a phone number that is <b>already registered</b> on telegram to get the API ID<br><b>'.$message.'</b>', '<input type="text" name="phone_number" placeholder="Phone number" required/>'));
} }
} else { } else {
if ($message) { if ($message) {