Update system and reference database bugfixes

This commit is contained in:
Daniil Gentili 2019-07-20 20:50:00 +02:00
parent 2f5dcf5daa
commit 261ce6401b
5 changed files with 27 additions and 7 deletions

View File

@ -59,7 +59,7 @@ class EventHandler extends \danog\MadelineProto\EventHandler
}
$settings = ['logger' => ['logger_level' => 5]];
$MadelineProto = new \danog\MadelineProto\API('bot.madeline', $settings);
$MadelineProto = new \danog\MadelineProto\API('testing.madeline', $settings);
$MadelineProto->async(true);
$MadelineProto->loop(function () use ($MadelineProto) {
yield $MadelineProto->start();

2
docs

@ -1 +1 @@
Subproject commit 8f6784adf5bca1dbab98ba1ec69ab52050633ca1
Subproject commit ddb2e4f76938b69ceac6e4615901c642accae1ef

View File

@ -123,7 +123,7 @@ class FeedLoop extends ResumableSignalLoop
$this->incomingUpdates = [];
continue;
}
if (isset($update['message']['id'], $update['message']['to_id']) && !in_array($update['_'], ['updateEditMessage', 'updateEditChannelMessage'])) {
if (isset($update['message']['id'], $update['message']['to_id']) && !in_array($update['_'], ['updateEditMessage', 'updateEditChannelMessage', 'updateMessageID'])) {
if (!$this->API->check_msg_id($update['message'])) {
$logger('MSGID duplicate');

View File

@ -988,12 +988,30 @@ class MTProto extends AsyncConstruct implements TLCallback
}
public function resetUpdateSystem()
public function resetUpdateState()
{
foreach ($this->channels_state->get() as $state) {
$channelId = $state->getChannel();
$this->channels_state->__construct([$channelId => new UpdatesState()]);
if (isset($this->seqUpdater)) {
$this->seqUpdater->signal(true);
}
$channelIds = [];
$newStates = [];
foreach ($this->channels_state->get() as $state) {
$channelIds[] = $state->getChannel();
$channelId = $state->getChannel();
$pts = $state->pts();
$pts = $channelId ? max(1, $pts-1000000) : ($pts > 4000000 ? $pts-1000000 : max(1, $pts-1000000));
$newStates[$channelId] = new UpdatesState(['pts' => $pts], $channelId);
}
sort($channelIds);
foreach ($channelIds as $channelId) {
if (isset($this->feeders[$channelId])) {
$this->feeders[$channelId]->signal(true);
}
if (!isset($this->updaters[$channelId])) {
$this->updaters[$channelId]->signal(true);
}
}
$this->channels_state->__construct($newStates);
$this->startUpdateSystem();
}

View File

@ -382,6 +382,7 @@ class ReferenceDatabase implements TLCallback
$count = 0;
foreach ($res['photos'] as $photo) {
$origin['max_id'] = $photo['id'];
$dc_id = $photo['dc_id'];
$location = $this->serializeLocation(self::PHOTO_LOCATION, $photo);
if (isset($cache[$location])) {
@ -395,6 +396,7 @@ class ReferenceDatabase implements TLCallback
if (isset($photo['sizes'])) {
foreach ($photo['sizes'] as $size) {
if (isset($size['location'])) {
$size['location']['dc_id'] = $dc_id;
$location = $this->serializeLocation(self::PHOTO_LOCATION_LOCATION, $size['location']);
if (isset($cache[$location])) {
$reference = $cache[$location];