Skip to content

Commit 6e2713f

Browse files
committed
Fix QR code logins
1 parent c6dabbd commit 6e2713f

6 files changed

Lines changed: 14 additions & 4 deletions

File tree

psalm-baseline.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7187,6 +7187,7 @@
71877187
<code><![CDATA[$tl['layer'] ?? -1]]></code>
71887188
<code><![CDATA[$tl['layer'] ?? -1]]></code>
71897189
<code><![CDATA[$type]]></code>
7190+
<code><![CDATA[$type['connection']]]></code>
71907191
<code><![CDATA[$type['subtype']]]></code>
71917192
<code><![CDATA[$type['type']]]></code>
71927193
<code><![CDATA[$type['type']]]></code>

src/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ public function getDatacenterID(): string
228228
{
229229
return $this->datacenterId;
230230
}
231+
public function getDatacenter(): int
232+
{
233+
return $this->datacenter;
234+
}
231235
/**
232236
* Get connection context.
233237
*/

src/MTProto.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,6 +1996,11 @@ public function populateConfig(array $config): void
19961996
{
19971997
$this->config = $config;
19981998
}
1999+
/** @internal */
2000+
public function handleAuthorization(array $authorization, Connection $connection): void
2001+
{
2002+
EventLoop::queue($this->processAuthorization(...), $authorization, $connection->getDatacenter());
2003+
}
19992004
/**
20002005
* @internal
20012006
*/
@@ -2005,6 +2010,7 @@ public function getConstructorAfterDeserializationCallbacks(): array
20052010
return [
20062011
'help.support' => [$this->populateSupportUser(...)],
20072012
'config' => [$this->populateConfig(...)],
2013+
'auth.authorization' => [$this->handleAuthorization(...)],
20082014
];
20092015
}
20102016
/**

src/MTProtoSession/ResponseHandler.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,6 @@ private function handleResponse(MTProtoIncomingMessage $message, ?int $requestId
236236
}
237237
$request->reply(static fn () => RPCErrorException::make('Received bad_msg_notification: ' . MTProto::BAD_MSG_ERROR_CODES[$response['error_code']], $response['error_code'], $request->constructor));
238238
return;
239-
} elseif ($constructor === 'auth.authorization') {
240-
EventLoop::queue($this->API->processAuthorization(...), $response, $this->datacenter);
241239
}
242240

243241
if (isset($response['_']) && !$this->shared->auth->isCdn) {

src/TL/TL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ public function deserialize($stream, array $type)
11111111
if ($type['encrypted']) {
11121112
if (isset($this->afterConstructorDeserialization[$x['_']])) {
11131113
foreach ($this->afterConstructorDeserialization[$x['_']] as $callback) {
1114-
$callback($x);
1114+
$callback($x, $type['connection']);
11151115
}
11161116
} elseif ($x['_'] === 'rpc_result'
11171117
&& isset($type['connection']->new_outgoing[$x['req_msg_id']])

src/TL/TLCallback.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
namespace danog\MadelineProto\TL;
2222

23+
use danog\MadelineProto\Connection;
2324
use danog\MadelineProto\MTProto\MTProtoOutgoingMessage;
2425

2526
/**
@@ -28,7 +29,7 @@
2829
*
2930
* @psalm-type TBeforeConstructorSerialization=Closure(array): mixed
3031
* @psalm-type TBeforeConstructorDeserialization=Closure(string): void
31-
* @psalm-type TAfterConstructorDeserialization=Closure(array): void
32+
* @psalm-type TAfterConstructorDeserialization=Closure(array, Connection): void
3233
* @psalm-type TTypeMismatch=Closure(array): mixed
3334
*
3435
* @internal Interface for managing TL serialization callbacks.

0 commit comments

Comments
 (0)