1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 04:08:59 +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\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 {

View File

@ -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').'|';
}

View File

@ -559,7 +559,8 @@ class MTProto extends AsyncConstruct implements TLCallback
* @internal
* @return array<RSA>
*/
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;
}
/**

View File

@ -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;
}
/**

View File

@ -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!");

View File

@ -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",