Fixes for old sessions

This commit is contained in:
Daniil Gentili 2017-09-25 22:33:37 +02:00
parent ef49c56407
commit f168b0134a

View File

@ -359,8 +359,10 @@ class MTProto
} }
$this->setup_threads(); $this->setup_threads();
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']); $this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
if ($this->get_self()) {
$this->authorized = self::LOGGED_IN;
}
if ($this->authorized === self::LOGGED_IN) { if ($this->authorized === self::LOGGED_IN) {
$this->get_self();
$this->get_cdn_config($this->datacenter->curdc); $this->get_cdn_config($this->datacenter->curdc);
$this->setup_logger(); $this->setup_logger();
} }
@ -794,10 +796,9 @@ class MTProto
public function get_self() public function get_self()
{ {
if ($this->authorization === null) { try {
$this->authorization = ['user' => $this->method_call('users.getUsers', ['id' => [['_' => 'inputUserSelf']]], ['datacenter' => $this->datacenter->curdc])[0]]; $this->authorization = ['user' => $this->method_call('users.getUsers', ['id' => [['_' => 'inputUserSelf']]], ['datacenter' => $this->datacenter->curdc])[0]];
} } catch (RPCErrorException $e) { return false; }
return $this->authorization['user']; return $this->authorization['user'];
} }