mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 07:38:58 +01:00
TAS hotfixes
This commit is contained in:
parent
29057d31e7
commit
81b5c5e9ae
@ -71,7 +71,7 @@ final class ReadLoop extends Loop
|
||||
$this->API->logger("Got NothingInTheSocketException in DC {$this->datacenter}, disconnecting because we have nothing to do...", Logger::ERROR);
|
||||
$this->connection->disconnect(true);
|
||||
} else {
|
||||
$this->API->logger($e);
|
||||
$this->API->logger($e, Logger::ERROR);
|
||||
$this->API->logger("Got exception in DC {$this->datacenter}, reconnecting...", Logger::ERROR);
|
||||
$this->connection->reconnect();
|
||||
}
|
||||
|
@ -408,6 +408,7 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
*/
|
||||
#[OrmMappedArray(KeyType::STRING, ValueType::SCALAR, cacheTtl: 0, optimizeIfWastedMb: 1, tablePostfix: 'session')]
|
||||
public DbArray $sessionDb;
|
||||
private bool $cleaned = false;
|
||||
|
||||
/**
|
||||
* Returns an instance of a client by session name.
|
||||
@ -1003,6 +1004,11 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
$this->updateQueue = $q;
|
||||
}
|
||||
|
||||
if ($this->cleaned) {
|
||||
return;
|
||||
}
|
||||
$this->cleaned = true;
|
||||
|
||||
if (isset($this->channels_state)) {
|
||||
$this->updateState = new CombinedUpdatesState;
|
||||
foreach ($this->channels_state->get() as $channelId => $state) {
|
||||
@ -1125,6 +1131,9 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
$this->initPromise = $deferred->getFuture();
|
||||
|
||||
try {
|
||||
// Update settings from constructor
|
||||
$this->updateSettings($settings);
|
||||
|
||||
// Setup logger
|
||||
$this->setupLogger();
|
||||
|
||||
@ -1154,8 +1163,6 @@ final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
|
||||
}
|
||||
// Reset MTProto session (not related to user session)
|
||||
$this->resetMTProtoSession("wakeup");
|
||||
// Update settings from constructor
|
||||
$this->updateSettings($settings);
|
||||
// Update TL callbacks
|
||||
$callbacks = [$this, $this->peerDatabase];
|
||||
if ($this->settings->getDb()->getEnableFileReferenceDb()) {
|
||||
|
@ -240,7 +240,14 @@ trait FilesLogic
|
||||
if ($result->shouldServe()) {
|
||||
$pipe = new Pipe(1024 * 1024);
|
||||
[$start, $end] = $result->getServeRange();
|
||||
EventLoop::queue($this->downloadToStream(...), $messageMedia, $pipe->getSink(), $cb, $start, $end, $cancellation);
|
||||
EventLoop::queue(function() use($messageMedia, $pipe, $cb, $start, $end, $cancellation) {
|
||||
try {
|
||||
$this->downloadToStream($messageMedia, $pipe->getSink(), $cb, $start, $end, $cancellation);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->logger($e, Logger::ERROR);
|
||||
}
|
||||
$pipe->getSink()->close();
|
||||
});
|
||||
$body = $pipe->getSource();
|
||||
} elseif (!\in_array($result->getCode(), [HttpStatus::OK, HttpStatus::PARTIAL_CONTENT], true)) {
|
||||
$body = $result->getCodeExplanation();
|
||||
|
@ -266,11 +266,13 @@ final class PeerDatabase implements TLCallback
|
||||
}
|
||||
$new = self::getUsernames($new);
|
||||
$old = $old ? self::getUsernames($old) : [];
|
||||
$diffToRemove = array_diff($old, $new);
|
||||
$diffToAdd = array_diff($new, $old);
|
||||
if (!$diffToAdd && !$diffToRemove) {
|
||||
return;
|
||||
foreach ($old as $key => $username) {
|
||||
if (!isset($this->usernames[$username])) {
|
||||
unset($old[$key]);
|
||||
}
|
||||
}
|
||||
$diffToRemove = array_diff($old, $new);
|
||||
$diffToAdd = array_diff($new, $diffToRemove);
|
||||
$lock = $this->decacheMutex->acquire();
|
||||
try {
|
||||
foreach ($diffToRemove as $username) {
|
||||
@ -410,6 +412,9 @@ final class PeerDatabase implements TLCallback
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->recacheChatUsername($user['id'], $existingChat, $user);
|
||||
|
||||
if ($existingChat != $user) {
|
||||
$this->API->logger("Updated user {$user['id']}", Logger::ULTRA_VERBOSE);
|
||||
if (($user['min'] ?? false) && !($existingChat['min'] ?? false)) {
|
||||
@ -419,7 +424,7 @@ final class PeerDatabase implements TLCallback
|
||||
$user['access_hash'] = $existingChat['access_hash'];
|
||||
}
|
||||
}
|
||||
$this->recacheChatUsername($user['id'], $existingChat, $user);
|
||||
|
||||
if (!$this->API->settings->getDb()->getEnablePeerInfoDb()) {
|
||||
$user = [
|
||||
'_' => $user['_'],
|
||||
@ -544,8 +549,8 @@ final class PeerDatabase implements TLCallback
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($existingChat != $chat) {
|
||||
$this->recacheChatUsername($bot_api_id, $existingChat, $chat);
|
||||
if ($existingChat != $chat) {
|
||||
$this->API->logger("Updated chat {$bot_api_id}", Logger::ULTRA_VERBOSE);
|
||||
if (($chat['min'] ?? false) && $existingChat && !($existingChat['min'] ?? false)) {
|
||||
$this->API->logger("{$bot_api_id} is min, filling missing fields", Logger::ULTRA_VERBOSE);
|
||||
|
Loading…
Reference in New Issue
Block a user