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