Remove old synchronous methods
This commit is contained in:
parent
db2eadb217
commit
fcad92d7cb
@ -459,10 +459,6 @@ trait AuthKeyHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_dh_config()
|
|
||||||
{
|
|
||||||
return $this->wait($this->get_dh_config_async());
|
|
||||||
}
|
|
||||||
public function get_dh_config_async()
|
public function get_dh_config_async()
|
||||||
{
|
{
|
||||||
$this->updates_state['sync_loading'] = true;
|
$this->updates_state['sync_loading'] = true;
|
||||||
@ -564,11 +560,6 @@ trait AuthKeyHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creates authorization keys
|
// Creates authorization keys
|
||||||
public function init_authorization()
|
|
||||||
{
|
|
||||||
return $this->wait($this->init_authorization_async());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function init_authorization_async()
|
public function init_authorization_async()
|
||||||
{
|
{
|
||||||
if ($this->pending_auth) {
|
if ($this->pending_auth) {
|
||||||
|
@ -60,13 +60,13 @@ trait CallHandler
|
|||||||
$this->datacenter->sockets[$new_datacenter]->writer->resume();
|
$this->datacenter->sockets[$new_datacenter]->writer->resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public function method_call($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false])
|
public function method_call($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false])
|
||||||
{
|
{
|
||||||
$promise = $this->method_call_async_read($method, $args, $aargs);
|
$promise = $this->method_call_async_read($method, $args, $aargs);
|
||||||
|
|
||||||
return $this->wait($promise);
|
return $this->wait($promise);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public function method_call_async_read($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]): Promise
|
public function method_call_async_read($method, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]): Promise
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ trait Files
|
|||||||
return $this->upload_async($file, $file_name, $cb, true);
|
return $this->upload_async($file, $file_name, $cb, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gen_all_file($media, $regenerate)
|
public function gen_all_file_async($media, $regenerate)
|
||||||
{
|
{
|
||||||
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
|
$res = [$this->constructors->find_by_predicate($media['_'])['type'] => $media];
|
||||||
switch ($media['_']) {
|
switch ($media['_']) {
|
||||||
@ -164,7 +164,7 @@ trait Files
|
|||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
}
|
}
|
||||||
$res['Photo'] = $media['photo'];
|
$res['Photo'] = $media['photo'];
|
||||||
$res['InputPhoto'] = ['_' => 'inputPhoto', 'id' => $media['photo']['id'], 'access_hash' => $media['photo']['access_hash'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION, $media['photo']))];
|
$res['InputPhoto'] = ['_' => 'inputPhoto', 'id' => $media['photo']['id'], 'access_hash' => $media['photo']['access_hash'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION, $media['photo'])];
|
||||||
$res['InputMedia'] = ['_' => 'inputMediaPhoto', 'id' => $res['InputPhoto']];
|
$res['InputMedia'] = ['_' => 'inputMediaPhoto', 'id' => $res['InputPhoto']];
|
||||||
if (isset($media['ttl_seconds'])) {
|
if (isset($media['ttl_seconds'])) {
|
||||||
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
||||||
@ -175,7 +175,7 @@ trait Files
|
|||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
}
|
}
|
||||||
$res['Document'] = $media['document'];
|
$res['Document'] = $media['document'];
|
||||||
$res['InputDocument'] = ['_' => 'inputDocument', 'id' => $media['document']['id'], 'access_hash' => $media['document']['access_hash'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION, $media['document']))];
|
$res['InputDocument'] = ['_' => 'inputDocument', 'id' => $media['document']['id'], 'access_hash' => $media['document']['access_hash'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION, $media['document'])];
|
||||||
$res['InputMedia'] = ['_' => 'inputMediaDocument', 'id' => $res['InputDocument']];
|
$res['InputMedia'] = ['_' => 'inputMediaDocument', 'id' => $res['InputDocument']];
|
||||||
if (isset($media['ttl_seconds'])) {
|
if (isset($media['ttl_seconds'])) {
|
||||||
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
$res['InputMedia']['ttl_seconds'] = $media['ttl_seconds'];
|
||||||
@ -188,7 +188,7 @@ trait Files
|
|||||||
if (!isset($media['access_hash'])) {
|
if (!isset($media['access_hash'])) {
|
||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
}
|
}
|
||||||
$res['InputDocument'] = ['_' => 'inputDocument', 'id' => $media['id'], 'access_hash' => $media['access_hash'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION, $media))];
|
$res['InputDocument'] = ['_' => 'inputDocument', 'id' => $media['id'], 'access_hash' => $media['access_hash'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION, $media)];
|
||||||
$res['InputMedia'] = ['_' => 'inputMediaDocument', 'id' => $res['InputDocument']];
|
$res['InputMedia'] = ['_' => 'inputMediaDocument', 'id' => $res['InputDocument']];
|
||||||
$res['MessageMedia'] = ['_' => 'messageMediaDocument', 'document' => $media];
|
$res['MessageMedia'] = ['_' => 'messageMediaDocument', 'document' => $media];
|
||||||
break;
|
break;
|
||||||
@ -196,7 +196,7 @@ trait Files
|
|||||||
if (!isset($media['access_hash'])) {
|
if (!isset($media['access_hash'])) {
|
||||||
throw new \danog\MadelineProto\Exception('No access hash');
|
throw new \danog\MadelineProto\Exception('No access hash');
|
||||||
}
|
}
|
||||||
$res['InputPhoto'] = ['_' => 'inputPhoto', 'id' => $media['id'], 'access_hash' => $media['access_hash'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION, $media))];
|
$res['InputPhoto'] = ['_' => 'inputPhoto', 'id' => $media['id'], 'access_hash' => $media['access_hash'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION, $media)];
|
||||||
$res['InputMedia'] = ['_' => 'inputMediaPhoto', 'id' => $res['InputPhoto']];
|
$res['InputMedia'] = ['_' => 'inputMediaPhoto', 'id' => $res['InputPhoto']];
|
||||||
$res['MessageMedia'] = ['_' => 'messageMediaPhoto', 'photo' => $media];
|
$res['MessageMedia'] = ['_' => 'messageMediaPhoto', 'photo' => $media];
|
||||||
break;
|
break;
|
||||||
@ -347,7 +347,7 @@ trait Files
|
|||||||
throw new \danog\MadelineProto\Exception('File location unavailable');
|
throw new \danog\MadelineProto\Exception('File location unavailable');
|
||||||
case 'fileLocation':
|
case 'fileLocation':
|
||||||
$res['name'] = $message_media['volume_id'].'_'.$message_media['local_id'];
|
$res['name'] = $message_media['volume_id'].'_'.$message_media['local_id'];
|
||||||
$res['InputFileLocation'] = ['_' => 'inputFileLocation', 'volume_id' => $message_media['volume_id'], 'local_id' => $message_media['local_id'], 'secret' => $message_media['secret'], 'dc_id' => $message_media['dc_id'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION_LOCATION, $message_media))];
|
$res['InputFileLocation'] = ['_' => 'inputFileLocation', 'volume_id' => $message_media['volume_id'], 'local_id' => $message_media['local_id'], 'secret' => $message_media['secret'], 'dc_id' => $message_media['dc_id'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::PHOTO_LOCATION_LOCATION, $message_media)];
|
||||||
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], '.jpg');
|
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], '.jpg');
|
||||||
$res['mime'] = $this->get_mime_from_extension($res['ext'], 'image/jpeg');
|
$res['mime'] = $this->get_mime_from_extension($res['ext'], 'image/jpeg');
|
||||||
|
|
||||||
@ -380,7 +380,7 @@ trait Files
|
|||||||
$res['name'] .= ' - '.$audio['performer'];
|
$res['name'] .= ' - '.$audio['performer'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$res['InputFileLocation'] = ['_' => 'inputDocumentFileLocation', 'id' => $message_media['document']['id'], 'access_hash' => $message_media['document']['access_hash'], 'version' => isset($message_media['document']['version']) ? $message_media['document']['version'] : 0, 'dc_id' => $message_media['document']['dc_id'], 'file_reference' => $this->wait($this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION_LOCATION, $message_media['document']))];
|
$res['InputFileLocation'] = ['_' => 'inputDocumentFileLocation', 'id' => $message_media['document']['id'], 'access_hash' => $message_media['document']['access_hash'], 'version' => isset($message_media['document']['version']) ? $message_media['document']['version'] : 0, 'dc_id' => $message_media['document']['dc_id'], 'file_reference' => yield $this->referenceDatabase->getReference(ReferenceDatabase::DOCUMENT_LOCATION_LOCATION, $message_media['document'])];
|
||||||
if (!isset($res['ext'])) {
|
if (!isset($res['ext'])) {
|
||||||
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], $this->get_extension_from_mime($message_media['document']['mime_type']));
|
$res['ext'] = yield $this->get_extension_from_location_async($res['InputFileLocation'], $this->get_extension_from_mime($message_media['document']['mime_type']));
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ class ReferenceDatabase implements TLCallback
|
|||||||
|
|
||||||
public function getConstructorSerializeCallbacks(): array
|
public function getConstructorSerializeCallbacks(): array
|
||||||
{
|
{
|
||||||
return array_fill_keys(array_keys(self::LOCATION_CONTEXT), [$this, 'populateReferenceSync']);
|
return array_fill_keys(array_keys(self::LOCATION_CONTEXT), [$this, 'populateReference']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTypeMismatchCallbacks(): array
|
public function getTypeMismatchCallbacks(): array
|
||||||
@ -532,11 +532,6 @@ class ReferenceDatabase implements TLCallback
|
|||||||
throw new Exception('Did not refresh reference');
|
throw new Exception('Did not refresh reference');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function populateReferenceSync(array $object): array
|
|
||||||
{
|
|
||||||
return $this->wait($this->populateReference($object));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function populateReference(array $object): Promise
|
public function populateReference(array $object): Promise
|
||||||
{
|
{
|
||||||
$deferred = new Deferred();
|
$deferred = new Deferred();
|
||||||
|
@ -232,24 +232,24 @@ trait UpdateHandler
|
|||||||
public function set_update_state_async($data)
|
public function set_update_state_async($data)
|
||||||
{
|
{
|
||||||
if (isset($data['pts']) && $data['pts'] !== 0) {
|
if (isset($data['pts']) && $data['pts'] !== 0) {
|
||||||
yield $this->load_update_state_async()['pts'] = $data['pts'];
|
(yield $this->load_update_state_async())['pts'] = $data['pts'];
|
||||||
}
|
}
|
||||||
if (isset($data['qts']) && $data['qts'] !== 0) {
|
if (isset($data['qts']) && $data['qts'] !== 0) {
|
||||||
yield $this->load_update_state_async()['qts'] = $data['qts'];
|
(yield $this->load_update_state_async())['qts'] = $data['qts'];
|
||||||
}
|
}
|
||||||
if (isset($data['seq']) && $data['seq'] !== 0) {
|
if (isset($data['seq']) && $data['seq'] !== 0) {
|
||||||
yield $this->load_update_state_async()['seq'] = $data['seq'];
|
(yield $this->load_update_state_async())['seq'] = $data['seq'];
|
||||||
}
|
}
|
||||||
if (isset($data['date']) && $data['date'] > yield $this->load_update_state_async()['date']) {
|
if (isset($data['date']) && $data['date'] > (yield $this->load_update_state_async())['date']) {
|
||||||
yield $this->load_update_state_async()['date'] = $data['date'];
|
(yield $this->load_update_state_async())['date'] = $data['date'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function reset_update_state_async()
|
public function reset_update_state_async()
|
||||||
{
|
{
|
||||||
yield $this->load_update_state_async()['pts'] = 1;
|
(yield $this->load_update_state_async())['pts'] = 1;
|
||||||
yield $this->load_update_state_async()['qts'] = 0;
|
(yield $this->load_update_state_async())['qts'] = 0;
|
||||||
yield $this->load_update_state_async()['seq'] = 0;
|
(yield $this->load_update_state_async())['seq'] = 0;
|
||||||
yield $this->load_update_state_async()['date'] = 1;
|
(yield $this->load_update_state_async())['date'] = 1;
|
||||||
foreach ($this->channels_state as &$state) {
|
foreach ($this->channels_state as &$state) {
|
||||||
$state['pts'] = 1;
|
$state['pts'] = 1;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ trait UpdateHandler
|
|||||||
$this->logger->logger('Fetching normal difference...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
$this->logger->logger('Fetching normal difference...', \danog\MadelineProto\Logger::ULTRA_VERBOSE);
|
||||||
while (!isset($difference)) {
|
while (!isset($difference)) {
|
||||||
try {
|
try {
|
||||||
$difference = yield $this->method_call_async_read('updates.getDifference', ['pts' => yield $this->load_update_state_async()['pts'], 'date' => yield $this->load_update_state_async()['date'], 'qts' => yield $this->load_update_state_async()['qts']], ['datacenter' => $this->settings['connection_settings']['default_dc']]);
|
$difference = yield $this->method_call_async_read('updates.getDifference', ['pts' => (yield $this->load_update_state_async())['pts'], 'date' => (yield $this->load_update_state_async())['date'], 'qts' => (yield $this->load_update_state_async())['qts']], ['datacenter' => $this->settings['connection_settings']['default_dc']]);
|
||||||
} catch (\danog\MadelineProto\PTSException $e) {
|
} catch (\danog\MadelineProto\PTSException $e) {
|
||||||
$this->updates_state['sync_loading'] = false;
|
$this->updates_state['sync_loading'] = false;
|
||||||
$this->got_state = false;
|
$this->got_state = false;
|
||||||
@ -388,7 +388,7 @@ trait UpdateHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($channel_id === false) {
|
if ($channel_id === false) {
|
||||||
$cur_state = &yield $this->load_update_state_async();
|
$cur_state = yield $this->load_update_state_async();
|
||||||
} else {
|
} else {
|
||||||
$cur_state = &$this->load_channel_state($channel_id, (isset($update['pts']) ? $update['pts'] : 0) - (isset($update['pts_count']) ? $update['pts_count'] : 0));
|
$cur_state = &$this->load_channel_state($channel_id, (isset($update['pts']) ? $update['pts'] : 0) - (isset($update['pts_count']) ? $update['pts_count'] : 0));
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ trait UpdateHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ($messages as $message) {
|
foreach ($messages as $message) {
|
||||||
yield $this->handle_update_async(['_' => $channel === false ? 'updateNewMessage' : 'updateNewChannelMessage', 'message' => $message, 'pts' => $channel === false ? yield $this->load_update_state_async()['pts'] : $this->load_channel_state($channel)['pts'], 'pts_count' => 0]);
|
yield $this->handle_update_async(['_' => $channel === false ? 'updateNewMessage' : 'updateNewChannelMessage', 'message' => $message, 'pts' => $channel === false ? (yield $this->load_update_state_async())['pts'] : $this->load_channel_state($channel)['pts'], 'pts_count' => 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,10 +108,6 @@ trait AuthKeyHandler
|
|||||||
$this->logger->logger('Secret chat '.$params['id'].' completed successfully!', \danog\MadelineProto\Logger::NOTICE);
|
$this->logger->logger('Secret chat '.$params['id'].' completed successfully!', \danog\MadelineProto\Logger::NOTICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notify_layer($chat)
|
|
||||||
{
|
|
||||||
return $this->wait($this->notify_layer_async($chat));
|
|
||||||
}
|
|
||||||
public function notify_layer_async($chat)
|
public function notify_layer_async($chat)
|
||||||
{
|
{
|
||||||
yield $this->method_call_async_read('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionNotifyLayer', 'layer' => $this->encrypted_layer]]], ['datacenter' => $this->datacenter->curdc]);
|
yield $this->method_call_async_read('messages.sendEncryptedService', ['peer' => $chat, 'message' => ['_' => 'decryptedMessageService', 'action' => ['_' => 'decryptedMessageActionNotifyLayer', 'layer' => $this->encrypted_layer]]], ['datacenter' => $this->datacenter->curdc]);
|
||||||
|
@ -405,7 +405,7 @@ trait TL
|
|||||||
$object['_'] = $constructorData['predicate'];
|
$object['_'] = $constructorData['predicate'];
|
||||||
}
|
}
|
||||||
if (isset($this->tl_callbacks[TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK][$object['_']])) {
|
if (isset($this->tl_callbacks[TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK][$object['_']])) {
|
||||||
$object = $this->tl_callbacks[TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK][$object['_']]($object);
|
$object = yield $this->tl_callbacks[TLCallback::CONSTRUCTOR_SERIALIZE_CALLBACK][$object['_']]($object);
|
||||||
}
|
}
|
||||||
|
|
||||||
$predicate = $object['_'];
|
$predicate = $object['_'];
|
||||||
|
@ -21,10 +21,6 @@ namespace danog\MadelineProto\Wrappers;
|
|||||||
|
|
||||||
trait DialogHandler
|
trait DialogHandler
|
||||||
{
|
{
|
||||||
public function get_dialogs($force = true)
|
|
||||||
{
|
|
||||||
return $this->wait($this->get_dialogs_async($force));
|
|
||||||
}
|
|
||||||
public function get_dialogs_async($force = true)
|
public function get_dialogs_async($force = true)
|
||||||
{
|
{
|
||||||
if ($force || !isset($this->dialog_params['offset_date']) || is_null($this->dialog_params['offset_date']) || !isset($this->dialog_params['offset_id']) || is_null($this->dialog_params['offset_id']) || !isset($this->dialog_params['offset_peer']) || is_null($this->dialog_params['offset_peer']) || !isset($this->dialog_params['count']) || is_null($this->dialog_params['count'])) {
|
if ($force || !isset($this->dialog_params['offset_date']) || is_null($this->dialog_params['offset_date']) || !isset($this->dialog_params['offset_id']) || is_null($this->dialog_params['offset_id']) || !isset($this->dialog_params['offset_peer']) || is_null($this->dialog_params['offset_peer']) || !isset($this->dialog_params['count']) || is_null($this->dialog_params['count'])) {
|
||||||
|
@ -28,10 +28,6 @@ use function Amp\Promise\wait;
|
|||||||
*/
|
*/
|
||||||
trait Login
|
trait Login
|
||||||
{
|
{
|
||||||
public function logout()
|
|
||||||
{
|
|
||||||
return $this->wait($this->logout_async());
|
|
||||||
}
|
|
||||||
public function logout_async()
|
public function logout_async()
|
||||||
{
|
{
|
||||||
foreach ($this->datacenter->sockets as $socket) {
|
foreach ($this->datacenter->sockets as $socket) {
|
||||||
|
Loading…
Reference in New Issue
Block a user