mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 00:34:40 +01:00
Do not delete secret chat/call creation updates
This commit is contained in:
parent
d1bed9e6a0
commit
890e4d65cc
@ -39,6 +39,8 @@ class Logger
|
||||
self::$has_thread = class_exists('\Thread') && method_exists('\Thread', 'getCurrentThread');
|
||||
self::$BIG_ENDIAN = (pack('L', 1) === pack('N', 1));
|
||||
self::$bigint = PHP_INT_SIZE < 8;
|
||||
if (class_exists('\danog\MadelineProto\VoIP')) \Threaded::extend('\danog\MadelineProto\VoIP');
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -65,12 +65,12 @@ class MTProto extends \Volatile
|
||||
'messages.acceptEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
'messages.discardEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
'messages.requestEncryption' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling secret chats',
|
||||
/*
|
||||
|
||||
'phone.requestCall' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling calls',
|
||||
'phone.acceptCall' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling calls',
|
||||
'phone.confirmCall' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling calls',
|
||||
'phone.discardCall' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling calls',
|
||||
*/
|
||||
|
||||
'updates.getChannelDifference' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getDifference' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
'updates.getState' => 'You cannot use this method directly, see https://daniil.it/MadelineProto for more info on handling updates',
|
||||
|
@ -452,6 +452,7 @@ trait UpdateHandler
|
||||
return;
|
||||
}
|
||||
if ($update['_'] === 'updatePhoneCall') {
|
||||
\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::WARNING);
|
||||
switch ($update['phone_call']['_']) {
|
||||
case 'phoneCallRequested':
|
||||
return $this->accept_call($update['phone_call']);
|
||||
@ -463,10 +464,7 @@ trait UpdateHandler
|
||||
$this->complete_call($update['phone_call']);
|
||||
break;
|
||||
case 'phoneCallDiscarded':
|
||||
\danog\MadelineProto\Logger::log(['Revoking call '.$update['phone_call']['id']], \danog\MadelineProto\Logger::NOTICE);
|
||||
if (isset($this->secret_chats[$update['phone_call']['id']])) {
|
||||
unset($this->secret_chats[$update['phone_call']['id']]);
|
||||
}
|
||||
$this->discard_call($update['phone_call']['id']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -505,7 +503,9 @@ trait UpdateHandler
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Accepting secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
return $this->accept_secret_chat($update['chat']);
|
||||
$this->accept_secret_chat($update['chat']);
|
||||
break;
|
||||
|
||||
case 'encryptedChatDiscarded':
|
||||
\danog\MadelineProto\Logger::log(['Deleting secret chat '.$update['chat']['id'].' because it was revoked by the other user'], \danog\MadelineProto\Logger::NOTICE);
|
||||
if (isset($this->secret_chats[$update['chat']['id']])) {
|
||||
@ -514,14 +514,13 @@ trait UpdateHandler
|
||||
if (isset($this->temp_requested_secret_chats[$update['chat']['id']])) {
|
||||
unset($this->temp_requested_secret_chats[$update['chat']['id']]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'encryptedChat':
|
||||
\danog\MadelineProto\Logger::log(['Completing creation of secret chat '.$update['chat']['id']], \danog\MadelineProto\Logger::NOTICE);
|
||||
|
||||
$this->complete_secret_chat($update['chat']);
|
||||
|
||||
return;
|
||||
break;
|
||||
}
|
||||
//\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::NOTICE);
|
||||
}
|
||||
|
@ -85,12 +85,10 @@ trait AuthKeyHandler
|
||||
foreach (str_split(strrev(substr(hash('sha256', $this->calls[$params['id']]['g_a']->toBytes().$key['auth_key'], true), 20)), 8) as $number) {
|
||||
$key['visualization'] .= self::EMOJIS[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
|
||||
}
|
||||
var_dump($this->calls[$params['id']]['class']);
|
||||
$this->calls[$params['id']] = ['status' => self::READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => 65, 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol'], 'controller' => new $this->calls[$params['id']]['class']($this, $params['id'])];
|
||||
$this->calls[$params['id']] = ['status' => self::READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => 65, 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol'], 'controller' => new $this->calls[$params['id']]['class']()];
|
||||
$this->calls[$params['id']]['controller']->setConfig($this->config['call_receive_timeout_ms'] / 1000, $this->config['call_connect_timeout_ms'] / 1000, \danog\MadelineProto\VoIP::DATA_SAVING_NEVER, true, true, true, $this->settings['calls']['log_file_path'], $this->settings['calls']['stats_dump_file_path']);
|
||||
$this->calls[$params['id']]['controller']->setEncryptionKey($key['auth_key'], true);
|
||||
$this->calls[$params['id']]['controller']->setNetworkType($this->settings['calls']['network_type']);
|
||||
|
||||
$this->calls[$params['id']]['controller']->setSharedConfig($this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]));
|
||||
$this->calls[$params['id']]['controller']->setRemoteEndpoints(array_merge([$res['connection']], $res['alternative_connections']), $params['protocol']['udp_p2p']);
|
||||
$this->calls[$params['id']]['controller']->start();
|
||||
@ -162,8 +160,28 @@ trait AuthKeyHandler
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function get_call($chat)
|
||||
public function get_call($call)
|
||||
{
|
||||
return $this->calls[$chat];
|
||||
return $this->calls[$call];
|
||||
}
|
||||
|
||||
public function discard_call($call)
|
||||
{
|
||||
\danog\MadelineProto\Logger::log(['Discarding call '.$call.'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
//var_dump(debug_backtrace(0)[0]);
|
||||
|
||||
|
||||
if (isset($this->calls[$call])) {
|
||||
if (isset($this->calls[$call]['InputPhoneCall'])) {
|
||||
try {
|
||||
$this->method_call('calls.discardCall', ['peer' => $this->calls[$call]['InputPhoneCall']], ['datacenter' => $this->datacenter->curdc]);
|
||||
} catch (\danog\MadelineProto\RPCErrorException $e) {
|
||||
if ($e->rpc !== 'CALL_ALREADY_DECLINED') {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($this->calls[$call]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,27 +96,22 @@ class pony extends \danog\MadelineProto\VoIP
|
||||
var_dump('STOP WRITING DATA');
|
||||
}
|
||||
|
||||
public function configureAudioOutput(int $sampleRate, int $bitsPerSample, int $channels)
|
||||
{
|
||||
var_dump("CONFIGURE AUDIO OUTPUT: sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
|
||||
}
|
||||
|
||||
public function configureAudioInput(int $sampleRate, int $bitsPerSample, int $channels)
|
||||
{
|
||||
var_dump("CONFIGURE AUDIO INPUT: sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
|
||||
}
|
||||
|
||||
public function getOutputLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public function debug($state) {
|
||||
var_dump("DEBUG $state"); flush();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
echo 'Serializing MadelineProto to session.madeline...'.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) {
|
||||
$start = false;
|
||||
var_dump($id = $MadelineProto->request_call('@magnaluna', '\pony'));
|
||||
var_dump($id = $MadelineProto->request_call('@danogentili', '\pony'));
|
||||
while (!$start) {
|
||||
$MadelineProto->get_updates();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user