mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:19:00 +01:00
Apply fixes from StyleCI
This commit is contained in:
parent
8c4ad60f84
commit
237638aecf
@ -86,8 +86,6 @@ class API extends APIFactory
|
||||
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['madelineproto_ready']], Logger::NOTICE);
|
||||
|
||||
Serialization::$instances[spl_object_hash($this)] = $this;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function __wakeup()
|
||||
|
@ -241,8 +241,6 @@ class MTProto
|
||||
$this->connect_to_all_dcs();
|
||||
$this->datacenter->curdc = 2;
|
||||
|
||||
|
||||
|
||||
if (!isset($this->authorization['user']['bot']) || !$this->authorization['user']['bot']) {
|
||||
try {
|
||||
$nearest_dc = $this->method_call('help.getNearestDc', [], ['datacenter' => $this->datacenter->curdc]);
|
||||
@ -369,8 +367,11 @@ class MTProto
|
||||
$force = true;
|
||||
foreach ($this->secret_chats as $chat => $data) {
|
||||
try {
|
||||
if (isset($this->secret_chats[$chat]) && $this->secret_chats[$chat]['InputEncryptedChat'] !== NULL) $this->notify_layer($chat);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {}
|
||||
if (isset($this->secret_chats[$chat]) && $this->secret_chats[$chat]['InputEncryptedChat'] !== null) {
|
||||
$this->notify_layer($chat);
|
||||
}
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$this->settings['updates']['handle_old_updates']) {
|
||||
|
@ -170,6 +170,7 @@ trait AuthKeyHandler
|
||||
{
|
||||
if ($this->secret_chats[$chat]['rekeying'][0] !== 1 || !isset($this->temp_rekeyed_secret_chats[$params['exchange_id']])) {
|
||||
$this->secret_chats[$chat]['rekeying'] = [0];
|
||||
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Committing rekeying of secret chat '.$chat.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
|
@ -87,6 +87,7 @@ trait MessageHandler
|
||||
|
||||
if ($this->secret_chats[$message['message']['chat_id']]['mtproto'] === 2) {
|
||||
\danog\MadelineProto\Logger::log(['Trying MTProto v2 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
try {
|
||||
$message_data = $this->try_mtproto_v2_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v2 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
@ -98,6 +99,7 @@ trait MessageHandler
|
||||
}
|
||||
} else {
|
||||
\danog\MadelineProto\Logger::log(['Trying MTProto v1 decryption for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
try {
|
||||
$message_data = $this->try_mtproto_v1_decrypt($message_key, $message['message']['chat_id'], $old, $encrypted_data);
|
||||
\danog\MadelineProto\Logger::log(['MTProto v1 decryption OK for chat '.$message['message']['chat_id'].'...'], \danog\MadelineProto\Logger::NOTICE);
|
||||
@ -121,7 +123,9 @@ trait MessageHandler
|
||||
|
||||
$this->handle_decrypted_update($message);
|
||||
}
|
||||
public function try_mtproto_v1_decrypt($message_key, $chat_id, $old, $encrypted_data) {
|
||||
|
||||
public function try_mtproto_v1_decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
{
|
||||
list($aes_key, $aes_iv) = $this->old_aes_calculate($message_key, $this->secret_chats[$chat_id][$old ? 'old_key' : 'key']['auth_key'], true);
|
||||
$decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv);
|
||||
|
||||
@ -143,7 +147,9 @@ trait MessageHandler
|
||||
|
||||
return $message_data;
|
||||
}
|
||||
public function try_mtproto_v2_decrypt($message_key, $chat_id, $old, $encrypted_data) {
|
||||
|
||||
public function try_mtproto_v2_decrypt($message_key, $chat_id, $old, $encrypted_data)
|
||||
{
|
||||
list($aes_key, $aes_iv) = $this->aes_calculate($message_key, $this->secret_chats[$chat_id][$old ? 'old_key' : 'key']['auth_key'], !$this->secret_chats[$chat_id]['admin']);
|
||||
$decrypted_data = $this->ige_decrypt($encrypted_data, $aes_key, $aes_iv);
|
||||
|
||||
@ -170,5 +176,4 @@ trait MessageHandler
|
||||
|
||||
return $message_data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,7 +45,9 @@ trait ResponseHandler
|
||||
if ($update['message']['decrypted_message']['action']['layer'] >= 17 && time() - $this->secret_chats[$update['message']['chat_id']]['created'] > 15) {
|
||||
$this->notify_layer($update['message']['chat_id']);
|
||||
}
|
||||
if ($update['message']['decrypted_message']['action']['layer'] >= 73) $this->secret_chats[$update['message']['chat_id']]['mtproto'] = 2;
|
||||
if ($update['message']['decrypted_message']['action']['layer'] >= 73) {
|
||||
$this->secret_chats[$update['message']['chat_id']]['mtproto'] = 2;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
@ -17,11 +17,18 @@ namespace danog\MadelineProto;
|
||||
*/
|
||||
class Serialization
|
||||
{
|
||||
static public $instances = [];
|
||||
static public function serialize_all($exception) {
|
||||
public static $instances = [];
|
||||
|
||||
public static function serialize_all($exception)
|
||||
{
|
||||
echo $exception.PHP_EOL;
|
||||
foreach (self::$instances as $instance) { if (isset($instance->session)) $instance->serialize(); }
|
||||
foreach (self::$instances as $instance) {
|
||||
if (isset($instance->session)) {
|
||||
$instance->serialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize API class.
|
||||
*
|
||||
@ -31,7 +38,7 @@ class Serialization
|
||||
*
|
||||
* @return number
|
||||
*/
|
||||
static public function serialize($filename, $instance, $force = false)
|
||||
public static function serialize($filename, $instance, $force = false)
|
||||
{
|
||||
if (isset($instance->API->setdem) && $instance->API->setdem) {
|
||||
$instance->API->setdem = false;
|
||||
@ -61,7 +68,7 @@ class Serialization
|
||||
*
|
||||
* @return API
|
||||
*/
|
||||
static public function deserialize($filename, $no_updates = false)
|
||||
public static function deserialize($filename, $no_updates = false)
|
||||
{
|
||||
if (file_exists($filename)) {
|
||||
if (!file_exists($lock = $filename.'.lock')) {
|
||||
|
Loading…
Reference in New Issue
Block a user