From 073aec1644f362a7c077e220624d6d9ae819f8ff Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 14 Aug 2022 14:40:52 +0200 Subject: [PATCH] Update --- docs | 2 +- schemas | 2 +- src/danog/MadelineProto/DataCenterConnection.php | 11 +++++------ src/danog/MadelineProto/DocsBuilder/Methods.php | 2 +- src/danog/MadelineProto/MTProto.php | 6 ++++-- src/danog/MadelineProto/MTProto/AuthKey.php | 12 ++++++++---- .../MadelineProto/MTProtoTools/AuthKeyHandler.php | 9 ++++----- vendor-bin/check/composer.json | 2 +- 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/docs b/docs index cba8a1e1b..5a78086c0 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit cba8a1e1bd5461800a1fd7e09cbfa51094e1c0e1 +Subproject commit 5a78086c01ef582ef1bf454a8c4c6475adbd22c1 diff --git a/schemas b/schemas index 89ec0d2f2..35c3dadd9 160000 --- a/schemas +++ b/schemas @@ -1 +1 @@ -Subproject commit 89ec0d2f2bcd64d579bdb41a1bfee2204d728dac +Subproject commit 35c3dadd9f69d54a2a04d05ab0dafce6efd3b003 diff --git a/src/danog/MadelineProto/DataCenterConnection.php b/src/danog/MadelineProto/DataCenterConnection.php index cc36cfd93..8de7d2764 100644 --- a/src/danog/MadelineProto/DataCenterConnection.php +++ b/src/danog/MadelineProto/DataCenterConnection.php @@ -23,7 +23,6 @@ use Amp\Deferred; use Amp\Promise; use Amp\Success; use Amp\Sync\LocalMutex; -use Amp\Sync\Lock; use danog\MadelineProto\Loop\Generic\PeriodicLoopInternal; use danog\MadelineProto\MTProto\AuthKey; use danog\MadelineProto\MTProto\OutgoingMessage; @@ -277,11 +276,11 @@ class DataCenterConnection implements JsonSerializable if ($this->API->authorized_dc !== -1 && $authorized_dc_id !== $this->API->authorized_dc) { continue; } - if ($authorized_socket->hasTempAuthKey() - && $authorized_socket->hasPermAuthKey() - && $authorized_socket->isAuthorized() - && $this->API->authorized === MTProto::LOGGED_IN - && !$this->isAuthorized() + if ($authorized_socket->hasTempAuthKey() + && $authorized_socket->hasPermAuthKey() + && $authorized_socket->isAuthorized() + && $this->API->authorized === MTProto::LOGGED_IN + && !$this->isAuthorized() && !$authorized_socket->isCDN() ) { try { diff --git a/src/danog/MadelineProto/DocsBuilder/Methods.php b/src/danog/MadelineProto/DocsBuilder/Methods.php index 70b14f9de..2bdd6fe11 100644 --- a/src/danog/MadelineProto/DocsBuilder/Methods.php +++ b/src/danog/MadelineProto/DocsBuilder/Methods.php @@ -170,7 +170,7 @@ trait Methods } } if (isset($this->tdDescriptions['methods'][$method])) { - $table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](/API_docs/'.$type_or_bare_type.'/'.$ptype.'.md) | '.$this->tdDescriptions['methods'][$method]['params'][$param['name']].' | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|'; + $table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](/API_docs/'.$type_or_bare_type.'/'.$ptype.'.md) | '.$this->tdDescriptions['methods'][$method]['params'][$param['name']].' | '.(isset($param['pow']) || $param['type'] === 'int' || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|'; } else { $table .= '|'.StrTools::markdownEscape($param['name']).'|'.(isset($param['subtype']) ? 'Array of ' : '').'['.StrTools::markdownEscape($human_ptype).'](/API_docs/'.$type_or_bare_type.'/'.$ptype.'.md) | '.(isset($param['pow']) || ($id = $this->TL->getConstructors($this->td)->findByPredicate(\lcfirst($param['type']).'Empty')) && $id['type'] === $param['type'] || ($id = $this->TL->getConstructors($this->td)->findByPredicate('input'.$param['type'].'Empty')) && $id['type'] === $param['type'] ? 'Optional' : 'Yes').'|'; } diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index b8b157ac6..f8b3d99db 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -559,7 +559,8 @@ class MTProto extends AsyncConstruct implements TLCallback * @internal * @return array */ - public function getRsaKeys(bool $test, bool $cdn): array{ + public function getRsaKeys(bool $test, bool $cdn): array + { if ($cdn) { return $this->cdn_rsa_keys; } @@ -1812,7 +1813,8 @@ class MTProto extends AsyncConstruct implements TLCallback /** * @internal */ - public function addConfig(array $config): void { + public function addConfig(array $config): void + { $this->config = $config; } /** diff --git a/src/danog/MadelineProto/MTProto/AuthKey.php b/src/danog/MadelineProto/MTProto/AuthKey.php index 6ef266278..98b5ab419 100644 --- a/src/danog/MadelineProto/MTProto/AuthKey.php +++ b/src/danog/MadelineProto/MTProto/AuthKey.php @@ -20,6 +20,7 @@ namespace danog\MadelineProto\MTProto; use JsonSerializable; +use Webmozart\Assert\Assert; /** * MTProto auth key. @@ -29,19 +30,19 @@ abstract class AuthKey implements JsonSerializable /** * Auth key. * - * @var string + * @var ?string */ protected $authKey; /** * Auth key ID. * - * @var string + * @var ?string */ protected $id; /** * Server salt. * - * @var string + * @var ?string */ protected $serverSalt; /** @@ -80,7 +81,7 @@ abstract class AuthKey implements JsonSerializable */ public function hasAuthKey(): bool { - return $this->authKey !== null; + return $this->authKey !== null && $this->serverSalt !== null; } /** * Get auth key. @@ -89,6 +90,7 @@ abstract class AuthKey implements JsonSerializable */ public function getAuthKey(): string { + Assert::notNull($this->authKey); return $this->authKey; } /** @@ -98,6 +100,7 @@ abstract class AuthKey implements JsonSerializable */ public function getID(): string { + Assert::notNull($this->id); return $this->id; } /** @@ -118,6 +121,7 @@ abstract class AuthKey implements JsonSerializable */ public function getServerSalt(): string { + Assert::notNull($this->serverSalt); return $this->serverSalt; } /** diff --git a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php index 7b1425850..49050dd32 100644 --- a/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php @@ -2,7 +2,6 @@ namespace danog\MadelineProto\MTProtoTools; -use Closure; use danog\MadelineProto\DataCenter; use danog\MadelineProto\Tools; use tgseclib\Math\BigInteger; @@ -13,12 +12,12 @@ use tgseclib\Math\BigInteger; trait AuthKeyHandler { /** - * Whether another initAuthorization is pending + * Whether another initAuthorization is pending. * * @var boolean */ private $pending_auth = false; - + /** * Asynchronously create, bind and check auth keys for all DCs. * @@ -58,8 +57,8 @@ trait AuthKeyHandler $first = \array_shift($main)(); yield from $first; } - yield Tools::all(array_map(fn ($cb) => $cb(), $main)); - yield Tools::all(array_map(fn ($cb) => $cb(), $media)); + yield Tools::all(\array_map(fn ($cb) => $cb(), $main)); + yield Tools::all(\array_map(fn ($cb) => $cb(), $media)); } while ($this->pending_auth); } finally { $this->logger("Done initing authorization!"); diff --git a/vendor-bin/check/composer.json b/vendor-bin/check/composer.json index 3771a3aa4..2e1653873 100644 --- a/vendor-bin/check/composer.json +++ b/vendor-bin/check/composer.json @@ -1,6 +1,6 @@ { "require": { - "vimeo/psalm": "dev-master", + "vimeo/psalm": "^4", "ennexa/amp-update-cache": "dev-master", "phpunit/phpunit": "^9", "amphp/php-cs-fixer-config": "dev-master",