1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-12-02 15:17:46 +01:00
This commit is contained in:
Daniil Gentili 2022-08-14 14:40:52 +02:00
parent cdab1b5e51
commit 073aec1644
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
8 changed files with 25 additions and 21 deletions

2
docs

@ -1 +1 @@
Subproject commit cba8a1e1bd5461800a1fd7e09cbfa51094e1c0e1 Subproject commit 5a78086c01ef582ef1bf454a8c4c6475adbd22c1

@ -1 +1 @@
Subproject commit 89ec0d2f2bcd64d579bdb41a1bfee2204d728dac Subproject commit 35c3dadd9f69d54a2a04d05ab0dafce6efd3b003

View File

@ -23,7 +23,6 @@ use Amp\Deferred;
use Amp\Promise; use Amp\Promise;
use Amp\Success; use Amp\Success;
use Amp\Sync\LocalMutex; use Amp\Sync\LocalMutex;
use Amp\Sync\Lock;
use danog\MadelineProto\Loop\Generic\PeriodicLoopInternal; use danog\MadelineProto\Loop\Generic\PeriodicLoopInternal;
use danog\MadelineProto\MTProto\AuthKey; use danog\MadelineProto\MTProto\AuthKey;
use danog\MadelineProto\MTProto\OutgoingMessage; use danog\MadelineProto\MTProto\OutgoingMessage;

View File

@ -170,7 +170,7 @@ trait Methods
} }
} }
if (isset($this->tdDescriptions['methods'][$method])) { 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 { } 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').'|'; $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').'|';
} }

View File

@ -559,7 +559,8 @@ class MTProto extends AsyncConstruct implements TLCallback
* @internal * @internal
* @return array<RSA> * @return array<RSA>
*/ */
public function getRsaKeys(bool $test, bool $cdn): array{ public function getRsaKeys(bool $test, bool $cdn): array
{
if ($cdn) { if ($cdn) {
return $this->cdn_rsa_keys; return $this->cdn_rsa_keys;
} }
@ -1812,7 +1813,8 @@ class MTProto extends AsyncConstruct implements TLCallback
/** /**
* @internal * @internal
*/ */
public function addConfig(array $config): void { public function addConfig(array $config): void
{
$this->config = $config; $this->config = $config;
} }
/** /**

View File

@ -20,6 +20,7 @@
namespace danog\MadelineProto\MTProto; namespace danog\MadelineProto\MTProto;
use JsonSerializable; use JsonSerializable;
use Webmozart\Assert\Assert;
/** /**
* MTProto auth key. * MTProto auth key.
@ -29,19 +30,19 @@ abstract class AuthKey implements JsonSerializable
/** /**
* Auth key. * Auth key.
* *
* @var string * @var ?string
*/ */
protected $authKey; protected $authKey;
/** /**
* Auth key ID. * Auth key ID.
* *
* @var string * @var ?string
*/ */
protected $id; protected $id;
/** /**
* Server salt. * Server salt.
* *
* @var string * @var ?string
*/ */
protected $serverSalt; protected $serverSalt;
/** /**
@ -80,7 +81,7 @@ abstract class AuthKey implements JsonSerializable
*/ */
public function hasAuthKey(): bool public function hasAuthKey(): bool
{ {
return $this->authKey !== null; return $this->authKey !== null && $this->serverSalt !== null;
} }
/** /**
* Get auth key. * Get auth key.
@ -89,6 +90,7 @@ abstract class AuthKey implements JsonSerializable
*/ */
public function getAuthKey(): string public function getAuthKey(): string
{ {
Assert::notNull($this->authKey);
return $this->authKey; return $this->authKey;
} }
/** /**
@ -98,6 +100,7 @@ abstract class AuthKey implements JsonSerializable
*/ */
public function getID(): string public function getID(): string
{ {
Assert::notNull($this->id);
return $this->id; return $this->id;
} }
/** /**
@ -118,6 +121,7 @@ abstract class AuthKey implements JsonSerializable
*/ */
public function getServerSalt(): string public function getServerSalt(): string
{ {
Assert::notNull($this->serverSalt);
return $this->serverSalt; return $this->serverSalt;
} }
/** /**

View File

@ -2,7 +2,6 @@
namespace danog\MadelineProto\MTProtoTools; namespace danog\MadelineProto\MTProtoTools;
use Closure;
use danog\MadelineProto\DataCenter; use danog\MadelineProto\DataCenter;
use danog\MadelineProto\Tools; use danog\MadelineProto\Tools;
use tgseclib\Math\BigInteger; use tgseclib\Math\BigInteger;
@ -13,7 +12,7 @@ use tgseclib\Math\BigInteger;
trait AuthKeyHandler trait AuthKeyHandler
{ {
/** /**
* Whether another initAuthorization is pending * Whether another initAuthorization is pending.
* *
* @var boolean * @var boolean
*/ */
@ -58,8 +57,8 @@ trait AuthKeyHandler
$first = \array_shift($main)(); $first = \array_shift($main)();
yield from $first; yield from $first;
} }
yield Tools::all(array_map(fn ($cb) => $cb(), $main)); 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(), $media));
} while ($this->pending_auth); } while ($this->pending_auth);
} finally { } finally {
$this->logger("Done initing authorization!"); $this->logger("Done initing authorization!");

View File

@ -1,6 +1,6 @@
{ {
"require": { "require": {
"vimeo/psalm": "dev-master", "vimeo/psalm": "^4",
"ennexa/amp-update-cache": "dev-master", "ennexa/amp-update-cache": "dev-master",
"phpunit/phpunit": "^9", "phpunit/phpunit": "^9",
"amphp/php-cs-fixer-config": "dev-master", "amphp/php-cs-fixer-config": "dev-master",