Secret chat fixes

This commit is contained in:
Daniil Gentili 2017-07-30 23:16:05 +02:00
parent 64f0562a49
commit b2e9930d16
4 changed files with 9 additions and 5 deletions

View File

@ -44,7 +44,7 @@ class MTProto extends \Volatile
use \danog\MadelineProto\Wrappers\DialogHandler;
use \danog\MadelineProto\Wrappers\Login;
const V = 66;
const V = 67;
const NOT_LOGGED_IN = 0;
const WAITING_CODE = 1;
@ -263,7 +263,7 @@ class MTProto extends \Volatile
public function __sleep()
{
return ['encrypted_layer', 'settings', 'config', 'authorization', 'authorized', 'rsa_keys', 'last_recv', 'dh_config', 'chats', 'last_stored', 'qres', 'pending_updates', 'updates_state', 'got_state', 'channels_state', 'updates', 'updates_key', 'full_chats', 'msg_ids', 'dialog_params', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'twoe1984', 'twoe2047', 'twoe2048', 'zero', 'one', 'two', 'three', 'four', 'temp_requested_secret_chats', 'temp_rekeyed_secret_chats', 'secret_chats', 'calls', 'hook_url', 'storage', 'emojis'];
return ['encrypted_layer', 'settings', 'config', 'authorization', 'authorized', 'rsa_keys', 'last_recv', 'dh_config', 'chats', 'last_stored', 'qres', 'pending_updates', 'updates_state', 'got_state', 'channels_state', 'updates', 'updates_key', 'full_chats', 'msg_ids', 'dialog_params', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'twoe1984', 'twoe2047', 'twoe2048', 'zero', 'one', 'two', 'three', 'four', 'temp_requested_secret_chats', 'temp_rekeyed_secret_chats', 'secret_chats', 'hook_url', 'storage', 'emojis'];
}
public function __wakeup()

View File

@ -34,7 +34,7 @@ trait MessageHandler
$this->secret_chats[$chat_id]['out_seq_no']++;
}
$this->secret_chats[$chat_id]['outgoing'][$this->secret_chats[$chat_id]['out_seq_no']] = $message;
$message = $this->serialize_object(['type' => $this->secret_chats[$chat_id]['layer'] === 8 ? 'DecryptedMessage' : 'DecryptedMessageLayer'], $message, 'decryptedMessage', $this->secret_chats[$chat_id]['layer']);
$message = $this->serialize_object(['type' => $constructor = $this->secret_chats[$chat_id]['layer'] === 8 ? 'DecryptedMessage' : 'DecryptedMessageLayer'], $message, $constructor, $this->secret_chats[$chat_id]['layer']);
$message = $this->pack_unsigned_int(strlen($message)).$message;
$message_key = substr(sha1($message, true), -16);

View File

@ -64,7 +64,11 @@ class TLConstructor extends \Volatile
{
if ($layer !== -1) {
foreach ($this->layers as $alayer) {
if ($alayer <= $layer && isset($this->by_predicate_and_layer[$predicate.$alayer])) {
if ($alayer <= $layer) {
if (isset($this->by_predicate_and_layer[$predicate.$alayer])) {
$chosenid = $this->by_predicate_and_layer[$predicate.$alayer];
}
} else if (!isset($chosenid)) {
$chosenid = $this->by_predicate_and_layer[$predicate.$alayer];
}
}

View File

@ -111,7 +111,7 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !==
}
}
}
echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
//echo 'Wrote '.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
}
}
if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) {