mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 09:58:59 +01:00
Cleanup
This commit is contained in:
parent
f01cb4092b
commit
f931dca964
@ -360,6 +360,9 @@ trait PeerHandler
|
||||
|
||||
/**
|
||||
* Get info about peer, returns an Info object.
|
||||
*
|
||||
* If passed a secret chat ID, returns information about the user, not about the secret chat.
|
||||
* Use getSecretChat to return information about the secret chat.
|
||||
*
|
||||
* @param mixed $id Peer
|
||||
* @param \danog\MadelineProto\API::INFO_TYPE_* $type Whether to generate an Input*, an InputPeer or the full set of constructors
|
||||
@ -385,21 +388,18 @@ trait PeerHandler
|
||||
if (\is_array($id)) {
|
||||
switch ($id['_']) {
|
||||
case 'updateEncryption':
|
||||
return $this->getSecretChat($id['chat']['id']);
|
||||
case 'inputEncryptedChat':
|
||||
case 'updateEncryptedChatTyping':
|
||||
case 'updateEncryptedMessagesRead':
|
||||
return $this->getSecretChat($id['chat_id']);
|
||||
$id = $this->getSecretChat($id['chat']['id'])->otherID;
|
||||
break;
|
||||
case 'updateNewEncryptedMessage':
|
||||
$id = $id['message'];
|
||||
// no break
|
||||
case 'inputEncryptedChat':
|
||||
case 'updateEncryptedChatTyping':
|
||||
case 'updateEncryptedMessagesRead':
|
||||
case 'encryptedMessage':
|
||||
case 'encryptedMessageService':
|
||||
$id = $id['chat_id'];
|
||||
if (!isset($this->secret_chats[$id])) {
|
||||
throw new SecretPeerNotInDbException;
|
||||
}
|
||||
return $this->secret_chats[$id];
|
||||
$id = $this->getSecretChat($id['chat_id'])->otherID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$folder_id = $this->getFolderId($id);
|
||||
@ -411,7 +411,7 @@ trait PeerHandler
|
||||
$id = (int) $id;
|
||||
Assert::true($id !== 0, "An invalid ID was specified!");
|
||||
if (DialogId::getType($id) === DialogId::SECRET_CHAT) {
|
||||
return $this->getSecretChat(DialogId::toSecretChatId($id));
|
||||
$id = $this->getSecretChat($id)->otherID;
|
||||
}
|
||||
if (!$this->peerDatabase->isset($id)) {
|
||||
try {
|
||||
|
@ -168,7 +168,21 @@ trait AuthKeyHandler
|
||||
public function getSecretChatController(array|int $chat): SecretChatController
|
||||
{
|
||||
if (\is_array($chat)) {
|
||||
return $this->getInfo($chat);
|
||||
switch ($chat['_']) {
|
||||
case 'updateEncryption':
|
||||
$chat = $chat['chat']['id'];
|
||||
break;
|
||||
case 'updateNewEncryptedMessage':
|
||||
$chat = $chat['message'];
|
||||
// no break
|
||||
case 'inputEncryptedChat':
|
||||
case 'updateEncryptedChatTyping':
|
||||
case 'updateEncryptedMessagesRead':
|
||||
case 'encryptedMessage':
|
||||
case 'encryptedMessageService':
|
||||
$chat = $chat['chat_id'];
|
||||
break;
|
||||
}
|
||||
} elseif (DialogId::isSecretChat($chat)) {
|
||||
$chat = DialogId::toSecretChatId($chat);
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ final class SecretChatController implements Stringable
|
||||
private int $in_seq_no_x;
|
||||
private int $out_seq_no_x;
|
||||
|
||||
public readonly array $inputChat;
|
||||
private int $ttl = 0;
|
||||
|
||||
private SecretFeedLoop $feedLoop;
|
||||
@ -100,10 +101,15 @@ final class SecretChatController implements Stringable
|
||||
/** @var TKey */
|
||||
private array $key,
|
||||
public readonly int $id,
|
||||
public readonly int $accessHash,
|
||||
int $accessHash,
|
||||
bool $creator,
|
||||
int $otherID,
|
||||
) {
|
||||
$this->inputChat = [
|
||||
'_' => 'inputEncryptedChat',
|
||||
'id' => $id,
|
||||
'access_hash' => $accessHash
|
||||
];
|
||||
if ($creator) {
|
||||
$this->in_seq_no_x = 1;
|
||||
$this->out_seq_no_x = 0;
|
||||
@ -128,7 +134,7 @@ final class SecretChatController implements Stringable
|
||||
{
|
||||
$this->initDb($this->API);
|
||||
}
|
||||
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
$vars = \get_object_vars($this);
|
||||
|
@ -732,14 +732,7 @@ final class TL implements TLInterface
|
||||
$arguments[$current_argument['name']] = ($this->API->upload($arguments[$current_argument['name']]));
|
||||
}
|
||||
if ($current_argument['type'] === 'InputEncryptedChat' && (!\is_array($arguments[$current_argument['name']]) || isset($arguments[$current_argument['name']]['_']) && $this->constructors->findByPredicate($arguments[$current_argument['name']]['_'])['type'] !== $current_argument['type'])) {
|
||||
if (\is_array($arguments[$current_argument['name']])) {
|
||||
$arguments[$current_argument['name']] = ($this->API->getInfo($arguments[$current_argument['name']]))['InputEncryptedChat'];
|
||||
} else {
|
||||
if (!$this->API->hasSecretChat($arguments[$current_argument['name']])) {
|
||||
throw new SecretPeerNotInDbException;
|
||||
}
|
||||
$arguments[$current_argument['name']] = $this->API->getSecretChat($arguments[$current_argument['name']])['InputEncryptedChat'];
|
||||
}
|
||||
$arguments[$current_argument['name']] = $this->API->getSecretChatController($arguments[$current_argument['name']])->inputChat;
|
||||
}
|
||||
//$this->API->logger->logger('Serializing '.$current_argument['name'].' of type '.$current_argument['type');
|
||||
$serialized .= ($this->serializeObject($current_argument, $arguments[$current_argument['name']], $current_argument['name'], $layer));
|
||||
|
Loading…
Reference in New Issue
Block a user