mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 23:14:38 +01:00
Fixes
This commit is contained in:
parent
fb077f380b
commit
d3fa21feb6
@ -1 +1 @@
|
||||
Subproject commit 538081f6ccfcc94a80144427a627da96b0d14408
|
||||
Subproject commit 25f83d460a9269b778435395935d9417530bcdf5
|
@ -293,6 +293,13 @@ final class PeerDatabase implements TLCallback
|
||||
|
||||
public function getIdFromUsername(string $username): ?int
|
||||
{
|
||||
foreach ($this->pendingDb as $key => $_) {
|
||||
if ($key < 0) {
|
||||
$this->processChat($key);
|
||||
} else {
|
||||
$this->processUser($key);
|
||||
}
|
||||
}
|
||||
return $this->usernames[$username];
|
||||
}
|
||||
|
||||
@ -326,6 +333,13 @@ final class PeerDatabase implements TLCallback
|
||||
} finally {
|
||||
unset($this->caching_simple_username[$username]);
|
||||
}
|
||||
foreach ($this->pendingDb as $key => $_) {
|
||||
if ($key < 0) {
|
||||
$this->processChat($key);
|
||||
} else {
|
||||
$this->processUser($key);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
/**
|
||||
@ -407,17 +421,29 @@ final class PeerDatabase implements TLCallback
|
||||
}
|
||||
}
|
||||
}
|
||||
public function addChatBlocking(array $chat): void
|
||||
public function addChatBlocking(int $chat): void
|
||||
{
|
||||
$id = $this->API->getIdInternal($chat);
|
||||
$this->pendingDb[$id] = $chat;
|
||||
$this->processChat($id);
|
||||
if (isset($this->pendingDb[$chat])) {
|
||||
$this->processChat($chat);
|
||||
} else {
|
||||
$this->pendingDb[$chat] = [
|
||||
'_' => 'channel',
|
||||
'id' => MTProto::fromSupergroup($chat),
|
||||
];
|
||||
$this->processChat($chat);
|
||||
}
|
||||
}
|
||||
public function addUserBlocking(array $user): void
|
||||
public function addUserBlocking(int $user): void
|
||||
{
|
||||
$id = $this->API->getIdInternal($user);
|
||||
$this->pendingDb[$id] = $user;
|
||||
$this->processUser($id);
|
||||
if (isset($this->pendingDb[$user])) {
|
||||
$this->processChat($user);
|
||||
} else {
|
||||
$this->pendingDb[$user] = [
|
||||
'_' => 'user',
|
||||
'id' => $user,
|
||||
];
|
||||
$this->processUser($user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Add chat to database.
|
||||
|
@ -430,17 +430,11 @@ trait PeerHandler
|
||||
try {
|
||||
$this->logger->logger("Try fetching {$id} with access hash 0");
|
||||
if ($this->isSupergroup($id)) {
|
||||
$this->peerDatabase->addChatBlocking([
|
||||
'_' => 'channel',
|
||||
'id' => $this->fromSupergroup($id),
|
||||
]);
|
||||
$this->peerDatabase->addChatBlocking($id);
|
||||
} elseif ($id < 0) {
|
||||
$this->methodCallAsyncRead('messages.getChats', ['id' => [-$id]]);
|
||||
} else {
|
||||
$this->peerDatabase->addUserBlocking([
|
||||
'_' => 'user',
|
||||
'id' => $id,
|
||||
]);
|
||||
$this->peerDatabase->addUserBlocking($id);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->logger->logger($e->getMessage(), Logger::WARNING);
|
||||
|
Loading…
Reference in New Issue
Block a user