Minor bugfixes and performance improvements

This commit is contained in:
Daniil Gentili 2019-05-13 11:38:54 +00:00
parent afbb08a027
commit be9c822d11
3 changed files with 7 additions and 4 deletions

View File

@ -61,7 +61,9 @@ trait ResponseHandler
$datacenter = $actual_datacenter;
}
$only_updates = true;
foreach ($this->datacenter->sockets[$datacenter]->new_incoming as $current_msg_id) {
while ($this->datacenter->sockets[$datacenter]->new_incoming) {
reset($this->datacenter->sockets[$datacenter]->new_incoming);
$current_msg_id = key($this->datacenter->sockets[$datacenter]->new_incoming);
$this->logger->logger((isset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['from_container']) ? 'Inside of container, received ' : 'Received ').$this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_'].' from DC '.$datacenter, \danog\MadelineProto\Logger::ULTRA_VERBOSE);
switch ($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']['_']) {
@ -127,8 +129,9 @@ trait ResponseHandler
$this->datacenter->sockets[$datacenter]->check_message_id($message['msg_id'], ['outgoing' => false, 'container' => true]);
$this->datacenter->sockets[$datacenter]->incoming_messages[$message['msg_id']] = ['seq_no' => $message['seqno'], 'content' => $message['body'], 'from_container' => true];
$this->datacenter->sockets[$datacenter]->new_incoming[$message['msg_id']] = $message['msg_id'];
$this->handle_messages($datacenter);
}
ksort($this->datacenter->sockets[$datacenter]->new_incoming);
$this->handle_messages($datacenter);
$this->datacenter->sockets[$datacenter]->check_in_seq_no($current_msg_id);
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);

View File

@ -370,7 +370,7 @@ trait BotAPI
$data['document']['_'] = 'bot_'.$type_name;
$res['file_size'] = $data['document']['size'];
$res['mime_type'] = $data['document']['mime_type'];
$res['file_id'] = $this->base64url_encode($this->rle_encode(yield $this->serialize_object_async(['type' => 'File'], $data['document'], 'File').chr(2)));
$res['file_id'] = $this->base64url_encode($this->rle_encode((yield $this->serialize_object_async(['type' => 'File'], $data['document'], 'File')).chr(2)));
return [$type_name => $res, 'caption' => isset($data['caption']) ? $data['caption'] : ''];
default:

View File

@ -76,7 +76,7 @@ trait BotAPIFiles
$photoSize['location']['access_hash'] = isset($photo['access_hash']) ? $photo['access_hash'] : 0;
$photoSize['location']['id'] = isset($photo['id']) ? $photo['id'] : 0;
$photoSize['location']['_'] = $thumbnail ? 'bot_thumbnail' : 'bot_photo';
$data = yield $this->serialize_object_async(['type' => 'File'], $photoSize['location'], 'File').chr(2);
$data = (yield $this->serialize_object_async(['type' => 'File'], $photoSize['location'], 'File')).chr(2);
return ['file_id' => $this->base64url_encode($this->rle_encode($data)), 'width' => $photoSize['w'], 'height' => $photoSize['h'], 'file_size' => isset($photoSize['size']) ? $photoSize['size'] : strlen($photoSize['bytes']), 'mime_type' => 'image/jpeg', 'file_name' => $photoSize['location']['volume_id'].'_'.$photoSize['location']['local_id'].$ext];
}