1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-23 07:31:11 +01:00

Peer database fixes

This commit is contained in:
Daniil Gentili 2023-08-15 10:14:43 +02:00
parent c3cbecbe66
commit 4fd02b351d
7 changed files with 40 additions and 22 deletions

2
docs

@ -1 +1 @@
Subproject commit af3d7da6a0802e4da78c66a7ed94c18d45d300cf
Subproject commit 36fed16a6e3260dc30b0c116d56fe392de71f84b

@ -1 +1 @@
Subproject commit 25f83d460a9269b778435395935d9417530bcdf5
Subproject commit 9f29cea871a595c4532e097201d1c819d23e27f9

@ -1 +1 @@
Subproject commit 1b75572b9f5492dbadcc142155768ba08a5f0a4c
Subproject commit a8e5d660b61d231960705c33a951a78ce11e27de

View File

@ -53,11 +53,14 @@ final class ActionForward implements Action
$id = \max($id, $update['message']['id']);
}
}
$this->API->methodCallAsyncRead(
'messages.updatePinnedMessage',
['peer' => $peer, 'id' => $id, 'unpin' => false, 'pm_oneside' => false],
['FloodWaitLimit' => 2*86400]
);
try {
$this->API->methodCallAsyncRead(
'messages.updatePinnedMessage',
['peer' => $peer, 'id' => $id, 'unpin' => false, 'pm_oneside' => false],
['FloodWaitLimit' => 2*86400]
);
} catch (RPCErrorException) {
}
}
} catch (RPCErrorException $e) {
if ($e->rpc === 'INPUT_USER_DEACTIVATED') {

View File

@ -49,11 +49,14 @@ final class ActionSend implements Action
));
}
if ($this->pin) {
$this->API->methodCallAsyncRead(
'messages.updatePinnedMessage',
['peer' => $peer, 'id' => $id, 'unpin' => false, 'pm_oneside' => false],
['FloodWaitLimit' => 2*86400]
);
try {
$this->API->methodCallAsyncRead(
'messages.updatePinnedMessage',
['peer' => $peer, 'id' => $id, 'unpin' => false, 'pm_oneside' => false],
['FloodWaitLimit' => 2*86400]
);
} catch (RPCErrorException) {
}
}
} catch (RPCErrorException $e) {
if ($e->rpc === 'INPUT_USER_DEACTIVATED') {

View File

@ -377,12 +377,12 @@ final class PeerDatabase implements TLCallback
if (!isset($this->pendingDb[$id])) {
return;
}
$user = $this->pendingDb[$id];
$lock = $this->mutex->acquire((string) $id);
try {
if (!isset($this->pendingDb[$id])) {
return;
}
$o = $user = $this->pendingDb[$id];
$existingChat = $this->db[$user['id']];
if (!isset($user['access_hash']) && !($user['min'] ?? false)) {
if (isset($existingChat['access_hash'])) {
@ -433,7 +433,9 @@ final class PeerDatabase implements TLCallback
}
}
} finally {
unset($this->pendingDb[$id]);
if ($this->pendingDb[$id] === $o) {
unset($this->pendingDb[$id]);
}
$lock->release();
}
}
@ -480,7 +482,10 @@ final class PeerDatabase implements TLCallback
}
$lock = $this->mutex->acquire((string) $id);
try {
$chat = $this->pendingDb[$id];
if (!isset($this->pendingDb[$id])) {
return;
}
$o = $chat = $this->pendingDb[$id];
if ($chat['_'] === 'chat'
|| $chat['_'] === 'chatEmpty'
|| $chat['_'] === 'chatForbidden'
@ -559,7 +564,9 @@ final class PeerDatabase implements TLCallback
}
}
} finally {
unset($this->pendingDb[$id]);
if ($this->pendingDb[$id] === $o) {
unset($this->pendingDb[$id]);
}
$lock->release();
}
}

View File

@ -173,10 +173,6 @@ final class VoIPController
);
return $data;
}
public function __destruct()
{
Logger::log("Destroyed $this");
}
/**
* Wakeup function.
*/
@ -503,7 +499,16 @@ final class VoIPController
{
foreach ($this->sockets as $socket) {
EventLoop::queue(function () use ($socket): void {
while ($payload = $socket->read()) {
while (true) {
try {
$payload = $socket->read();
} catch (Throwable $e) {
Logger::log("Got $e in this!");
continue;
}
if (!$payload) {
break;
}
$this->lastIncomingTimestamp = \microtime(true);
EventLoop::queue($this->handlePacket(...), $socket, $payload);
}