From b40a9570c05bd87f12a434ac2b1519f75957f07f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 21 Jun 2019 21:20:44 +0200 Subject: [PATCH] Bugfixes and improvements (subrelease) --- docs | 2 +- src/danog/MadelineProto/API.php | 1 + src/danog/MadelineProto/Loop/Update/UpdateLoop.php | 2 +- src/danog/MadelineProto/MTProto.php | 2 ++ src/danog/MadelineProto/Magic.php | 4 ++++ tests/makephar.sh | 6 ++++++ tests/testing.php | 8 ++++---- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs b/docs index c48c5f8c..3b2fb466 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit c48c5f8c0b94cedfe0cdc2dd72a534f1d17292df +Subproject commit 3b2fb46659932f3a812279b64f31b8933474978c diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 7b2b3e8b..3bd7b931 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -342,6 +342,7 @@ class API extends APIFactory flock($realpaths['lockfile'], LOCK_UN); fclose($realpaths['lockfile']); } + \danog\MadelineProto\Logger::log('Done serializing'); return $wrote; })()); diff --git a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php index 31270670..c7e00398 100644 --- a/src/danog/MadelineProto/Loop/Update/UpdateLoop.php +++ b/src/danog/MadelineProto/Loop/Update/UpdateLoop.php @@ -165,7 +165,7 @@ class UpdateLoop extends ResumableSignalLoop unset($difference); break 2; case 'updates.differenceSlice': - $state->qts($difference['state']['qts']); + $state->qts($difference['intermediate_state']['qts']); foreach ($difference['new_encrypted_messages'] as &$encrypted) { $encrypted = ['_' => 'updateNewEncryptedMessage', 'message' => $encrypted]; } diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 90545424..d422a087 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -30,6 +30,8 @@ use danog\MadelineProto\MTProtoTools\UpdatesState; use danog\MadelineProto\Stream\MTProtoTransport\HttpsStream; use danog\MadelineProto\Stream\MTProtoTransport\HttpStream; use danog\MadelineProto\TL\TLCallback; +use function Amp\ByteStream\getStdin; +use function Amp\ByteStream\getInputBufferStream; /** * Manages all of the mtproto stuff. diff --git a/src/danog/MadelineProto/Magic.php b/src/danog/MadelineProto/Magic.php index 37d6a2ce..ebc0efd9 100644 --- a/src/danog/MadelineProto/Magic.php +++ b/src/danog/MadelineProto/Magic.php @@ -25,6 +25,8 @@ use Amp\DoH\Rfc8484StubResolver; use Amp\Loop; use function Amp\Dns\resolver; use function Amp\Promise\wait; +use function Amp\ByteStream\getStdin; +use function Amp\ByteStream\getInputBufferStream; class Magic { @@ -143,6 +145,8 @@ class Magic if (defined('SIGINT')) { //if (function_exists('pcntl_async_signals')) pcntl_async_signals(true); Loop::onSignal(SIGINT, static function () { + getStdin()->unreference(); + getInputBufferStream()->unreference(); Logger::log('Got sigint', Logger::FATAL_ERROR); die(); }); diff --git a/tests/makephar.sh b/tests/makephar.sh index 2e346dc7..b1215ee6 100755 --- a/tests/makephar.sh +++ b/tests/makephar.sh @@ -121,6 +121,12 @@ cp ../phar.php ../mtproxyd . echo -n $TRAVIS_COMMIT > release$php$branch git add -A git commit -am "Release $TRAVIS_BRANCH - $TRAVIS_COMMIT_MESSAGE" + +echo "$TRAVIS_COMMIT_MESSAGE" | grep -i "subrelease" && { + cp release$php$branch release$php + cp madeline$php$branch.phar madeline$php.phar +} + git push origin master cd .. echo "$TRAVIS_COMMIT_MESSAGE" | grep "Apply fixes from StyleCI" && exit diff --git a/tests/testing.php b/tests/testing.php index c985617a..7469075c 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -78,7 +78,7 @@ $message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sem /* * Try making a phone call */ -if (!getenv('TRAVIS_COMMIT') && stripos(readline('Do you want to make a call? (y/n): '), 'y') !== false) { +if (!getenv('TRAVIS_COMMIT') && stripos($MadelineProto->readline('Do you want to make a call? (y/n): '), 'y') !== false) { $controller = $MadelineProto->request_call(getenv('TEST_SECRET_CHAT'))->play('input.raw')->then('input.raw')->playOnHold(['input.raw'])->setOutputFile('output.raw'); while ($controller->getCallState() < \danog\MadelineProto\VoIP::CALL_STATE_READY) { $MadelineProto->get_updates(); @@ -92,8 +92,8 @@ if (!getenv('TRAVIS_COMMIT') && stripos(readline('Do you want to make a call? (y /* * Try receiving a phone call */ -if (!getenv('TRAVIS_COMMIT') && stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !== false) { - $howmany = readline('How many calls would you like me to handle? '); +if (!getenv('TRAVIS_COMMIT') && stripos($MadelineProto->readline('Do you want to handle incoming calls? (y/n): '), 'y') !== false) { + $howmany = $MadelineProto->readline('How many calls would you like me to handle? '); $offset = 0; while ($howmany > 0) { $updates = $MadelineProto->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout @@ -114,7 +114,7 @@ if (!getenv('TRAVIS_COMMIT') && stripos(readline('Do you want to handle incoming /* * Secret chat usage */ -if (!getenv('TRAVIS_COMMIT') && stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) { +if (!getenv('TRAVIS_COMMIT') && stripos($MadelineProto->readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) { /** * Request a secret chat. */