mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:38:59 +01:00
Remove dead BC code
This commit is contained in:
parent
7d6ecf9148
commit
654e8dc87d
@ -204,7 +204,7 @@ final class UpdateLoop extends ResumableSignalLoop
|
|||||||
}
|
}
|
||||||
$API->logger->logger("Finished parsing updates in {$this}, now resuming feeders", Logger::ULTRA_VERBOSE);
|
$API->logger->logger("Finished parsing updates in {$this}, now resuming feeders", Logger::ULTRA_VERBOSE);
|
||||||
foreach ($result as $channelId => $_) {
|
foreach ($result as $channelId => $_) {
|
||||||
$API->feeders[$channelId]->resumeDefer();
|
$API->feeders[$channelId]?->resumeDefer();
|
||||||
}
|
}
|
||||||
$API->logger->logger("Finished resuming feeders in {$this}, signaling updates", Logger::ULTRA_VERBOSE);
|
$API->logger->logger("Finished resuming feeders in {$this}, signaling updates", Logger::ULTRA_VERBOSE);
|
||||||
$API->signalUpdate();
|
$API->signalUpdate();
|
||||||
|
@ -1005,19 +1005,15 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
$this->datacenter ??= new DataCenter($this, $this->dcList, $this->settings->getConnection());
|
$this->datacenter ??= new DataCenter($this, $this->dcList, $this->settings->getConnection());
|
||||||
$this->snitch ??= new Snitch;
|
$this->snitch ??= new Snitch;
|
||||||
|
|
||||||
|
$this->referenceDatabase ??= new ReferenceDatabase($this);
|
||||||
|
$this->minDatabase ??= new MinDatabase($this);
|
||||||
|
|
||||||
$db = [];
|
$db = [];
|
||||||
if (!isset($this->referenceDatabase)) {
|
$db []= async($this->referenceDatabase->init(...));
|
||||||
$this->referenceDatabase = new ReferenceDatabase($this);
|
$db []= async($this->minDatabase->init(...));
|
||||||
$db []= async($this->referenceDatabase->init(...));
|
$db []= async($this->initDb(...), $this);
|
||||||
} else {
|
await($db);
|
||||||
$db []= async($this->referenceDatabase->init(...));
|
|
||||||
}
|
|
||||||
if (!isset($this->minDatabase)) {
|
|
||||||
$this->minDatabase = new MinDatabase($this);
|
|
||||||
$db []= async($this->minDatabase->init(...));
|
|
||||||
} else {
|
|
||||||
$db []= async($this->minDatabase->init(...));
|
|
||||||
}
|
|
||||||
if (!isset($this->TL)) {
|
if (!isset($this->TL)) {
|
||||||
$this->TL = new TL($this);
|
$this->TL = new TL($this);
|
||||||
$callbacks = [$this, $this->referenceDatabase];
|
$callbacks = [$this, $this->referenceDatabase];
|
||||||
@ -1027,8 +1023,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
$this->TL->init($this->settings->getSchema(), $callbacks);
|
$this->TL->init($this->settings->getSchema(), $callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
$db []= async($this->initDb(...), $this);
|
|
||||||
await($db);
|
|
||||||
$this->fillUsernamesCache();
|
$this->fillUsernamesCache();
|
||||||
|
|
||||||
if (!$this->settings->getDb()->getEnableFullPeerDb()) {
|
if (!$this->settings->getDb()->getEnableFullPeerDb()) {
|
||||||
@ -1068,9 +1062,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
*/
|
*/
|
||||||
private function upgradeMadelineProto(): void
|
private function upgradeMadelineProto(): void
|
||||||
{
|
{
|
||||||
if (!isset($this->snitch)) {
|
|
||||||
$this->snitch = new Snitch;
|
|
||||||
}
|
|
||||||
$this->logger->logger(Lang::$current_lang['serialization_ofd'], Logger::WARNING);
|
$this->logger->logger(Lang::$current_lang['serialization_ofd'], Logger::WARNING);
|
||||||
foreach ($this->datacenter->getDataCenterConnections() as $dc_id => $socket) {
|
foreach ($this->datacenter->getDataCenterConnections() as $dc_id => $socket) {
|
||||||
if ($this->authorized === self::LOGGED_IN && \is_int($dc_id) && $socket->hasPermAuthKey() && $socket->hasTempAuthKey()) {
|
if ($this->authorized === self::LOGGED_IN && \is_int($dc_id) && $socket->hasPermAuthKey() && $socket->hasTempAuthKey()) {
|
||||||
@ -1079,58 +1070,7 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->settings->setSchema(new TLSchema);
|
$this->settings->setSchema(new TLSchema);
|
||||||
|
$this->usernames->clear();
|
||||||
$this->initDb($this);
|
|
||||||
|
|
||||||
foreach ($this->full_chats as $id => $full) {
|
|
||||||
if (isset($full['full'], $full['last_update'])) {
|
|
||||||
$this->full_chats->set($id, ['full' => $full['full'], 'last_update' => $full['last_update']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($this->channel_participants)) {
|
|
||||||
if (\is_array($this->channel_participants)) {
|
|
||||||
foreach ($this->channel_participants as $channelId => $filters) {
|
|
||||||
foreach ($filters as $filter => $qs) {
|
|
||||||
foreach ($qs as $q => $offsets) {
|
|
||||||
foreach ($offsets as $offset => $limits) {
|
|
||||||
foreach ($limits as $limit => $data) {
|
|
||||||
$this->channelParticipants[$this->participantsKey($channelId, $filter, $q, $offset, $limit)] = $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($this->channel_participants[$channelId]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self::$dbProperties['channel_participants'] = 'array';
|
|
||||||
$this->initDb($this);
|
|
||||||
foreach ($this->channel_participants as $channelId => $filters) {
|
|
||||||
foreach ($filters as $filter => $qs) {
|
|
||||||
foreach ($qs as $q => $offsets) {
|
|
||||||
foreach ($offsets as $offset => $limits) {
|
|
||||||
foreach ($limits as $limit => $data) {
|
|
||||||
$this->channelParticipants[$this->participantsKey($channelId, $filter, $q, $offset, $limit)] = $data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($this->channel_participants[$channelId]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($this->secret_chats as $key => &$chat) {
|
|
||||||
if (!\is_array($chat)) {
|
|
||||||
unset($this->secret_chats[$key]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($chat['layer'] >= 73) {
|
|
||||||
$chat['mtproto'] = 2;
|
|
||||||
} else {
|
|
||||||
$chat['mtproto'] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($chat);
|
|
||||||
|
|
||||||
$this->resetMTProtoSession(true, true);
|
$this->resetMTProtoSession(true, true);
|
||||||
$this->config = ['expires' => -1];
|
$this->config = ['expires' => -1];
|
||||||
@ -1144,8 +1084,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
} catch (RPCErrorException $e) {
|
} catch (RPCErrorException $e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->usernames->clear();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Post-deserialization initialization function.
|
* Post-deserialization initialization function.
|
||||||
@ -1156,20 +1094,20 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
*/
|
*/
|
||||||
public function wakeup(SettingsAbstract $settings, APIWrapper $wrapper): void
|
public function wakeup(SettingsAbstract $settings, APIWrapper $wrapper): void
|
||||||
{
|
{
|
||||||
|
// Setup one-time stuffs
|
||||||
|
Magic::start();
|
||||||
|
|
||||||
// Set reference to itself
|
// Set reference to itself
|
||||||
self::$references[\spl_object_hash($this)] = $this;
|
self::$references[\spl_object_hash($this)] = $this;
|
||||||
// Set API wrapper
|
// Set API wrapper
|
||||||
$this->wrapper = $wrapper;
|
$this->wrapper = $wrapper;
|
||||||
// BC stuff
|
|
||||||
if ($this->authorized === true) {
|
|
||||||
$this->authorized = self::LOGGED_IN;
|
|
||||||
}
|
|
||||||
$deferred = new DeferredFuture;
|
$deferred = new DeferredFuture;
|
||||||
$this->initPromise = $deferred->getFuture();
|
$this->initPromise = $deferred->getFuture();
|
||||||
|
|
||||||
if (!isset($this->snitch)) {
|
// Cleanup old properties, init new stuffs
|
||||||
$this->snitch = new Snitch;
|
$this->cleanupProperties();
|
||||||
}
|
|
||||||
// Re-set TL closures
|
// Re-set TL closures
|
||||||
$callbacks = [$this];
|
$callbacks = [$this];
|
||||||
if ($this->settings->getDb()->getEnableFileReferenceDb()) {
|
if ($this->settings->getDb()->getEnableFileReferenceDb()) {
|
||||||
@ -1178,21 +1116,9 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
if (!($this->authorization['user']['bot'] ?? false) && $this->settings->getDb()->getEnableMinDb()) {
|
if (!($this->authorization['user']['bot'] ?? false) && $this->settings->getDb()->getEnableMinDb()) {
|
||||||
$callbacks[] = $this->minDatabase;
|
$callbacks[] = $this->minDatabase;
|
||||||
}
|
}
|
||||||
$this->TL->updateCallbacks($callbacks);
|
|
||||||
// Convert old array settings to new settings object
|
|
||||||
if (\is_array($this->settings)) {
|
|
||||||
if (($this->settings['updates']['callback'] ?? '') === 'getUpdatesUpdateHandler') {
|
|
||||||
/** @psalm-suppress InvalidPropertyAssignmentValue */
|
|
||||||
$this->settings['updates']['callback'] = [$this, 'getUpdatesUpdateHandler'];
|
|
||||||
}
|
|
||||||
if (\is_callable($this->settings['updates']['callback'] ?? null)) {
|
|
||||||
$this->updateHandler = $this->settings['updates']['callback'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @psalm-suppress InvalidArrayOffset */
|
$this->TL->updateCallbacks($callbacks);
|
||||||
$this->dcList = $this->settings['connection'] ?? $this->dcList;
|
|
||||||
}
|
|
||||||
$this->settings = Settings::parseFromLegacy($this->settings);
|
|
||||||
// Clean up phone call array
|
// Clean up phone call array
|
||||||
foreach ($this->calls as $id => $controller) {
|
foreach ($this->calls as $id => $controller) {
|
||||||
if (!\is_object($controller)) {
|
if (!\is_object($controller)) {
|
||||||
@ -1205,8 +1131,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup one-time stuffs
|
|
||||||
Magic::start();
|
|
||||||
$this->settings->getConnection()->init();
|
$this->settings->getConnection()->init();
|
||||||
// Setup logger
|
// Setup logger
|
||||||
$this->setupLogger();
|
$this->setupLogger();
|
||||||
@ -1227,8 +1151,6 @@ final class MTProto implements TLCallback, LoggerGetter
|
|||||||
$this->upgradeMadelineProto();
|
$this->upgradeMadelineProto();
|
||||||
$forceDialogs = true;
|
$forceDialogs = true;
|
||||||
}
|
}
|
||||||
// Cleanup old properties, init new stuffs
|
|
||||||
$this->cleanupProperties();
|
|
||||||
// Update TL callbacks
|
// Update TL callbacks
|
||||||
$callbacks = [$this];
|
$callbacks = [$this];
|
||||||
if ($this->settings->getDb()->getEnableFileReferenceDb()) {
|
if ($this->settings->getDb()->getEnableFileReferenceDb()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user