Avoid JSON issues with request field and inflated photo payloads
This commit is contained in:
parent
22dd19a9de
commit
d3dc7a0155
@ -14,7 +14,7 @@ interface DbArray extends DbType, \ArrayAccess, \Countable
|
||||
public function offsetUnset($offset): Promise;
|
||||
public function count(): Promise;
|
||||
public function getIterator(): Producer;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @internal
|
||||
|
@ -5,7 +5,6 @@ namespace danog\MadelineProto\Db\Driver;
|
||||
use Amp\Redis\Config;
|
||||
use Amp\Redis\Redis as RedisRedis;
|
||||
use Amp\Redis\RemoteExecutorFactory;
|
||||
use Amp\Sql\Common\ConnectionPool;
|
||||
|
||||
class Redis
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ abstract class DriverArray implements DbArray
|
||||
{
|
||||
throw new \RuntimeException('Native isset not support promises. Use isset method');
|
||||
}
|
||||
|
||||
|
||||
abstract protected function initConnection(array $settings): \Generator;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ class MysqlArray extends SqlArray
|
||||
{
|
||||
return ['table', 'settings'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if key isset.
|
||||
*
|
||||
|
@ -476,7 +476,14 @@ trait ResponseHandler
|
||||
}
|
||||
$botAPI = isset($request['botAPI']) && $request['botAPI'];
|
||||
if (isset($response['_']) && !$this->isCdn() && $this->API->getTL()->getConstructors()->findByPredicate($response['_'])['type'] === 'Updates') {
|
||||
$response['request'] = ['_' => $request['_'], 'body' => $request['body'] ?? []];
|
||||
$body = [];
|
||||
if (isset($request['body']['peer'])) {
|
||||
$body['peer'] = $this->API->getID($request['body']['peer']);
|
||||
}
|
||||
if (isset($request['body']['message'])) {
|
||||
$body['message'] = (string) $request['body']['message'];
|
||||
}
|
||||
$response['request'] = ['_' => $request['_'], 'body' => $body];
|
||||
\danog\MadelineProto\Tools::callForkDefer($this->API->handleUpdates($response));
|
||||
}
|
||||
unset($request);
|
||||
|
@ -194,11 +194,11 @@ trait BotAPI
|
||||
case 'updateShortSentMessage':
|
||||
$newd['message_id'] = $data['id'];
|
||||
$newd['date'] = $data['date'];
|
||||
$newd['text'] = $data['request']['message'];
|
||||
$newd['text'] = $data['request']['body']['message'];
|
||||
if ($data['out']) {
|
||||
$newd['from'] = (yield from $this->getPwrChat($this->authorization['user']));
|
||||
}
|
||||
$newd['chat'] = yield from $this->getPwrChat($data['request']['peer']);
|
||||
$newd['chat'] = yield from $this->getPwrChat($data['request']['body']['peer']);
|
||||
if (isset($data['entities'])) {
|
||||
$newd['entities'] = yield from $this->MTProtoToBotAPI($data['entities']);
|
||||
}
|
||||
|
@ -1037,7 +1037,7 @@ class TL
|
||||
return $x['value'];
|
||||
}
|
||||
} elseif ($x['_'] === 'photoStrippedSize') {
|
||||
$x['inflated'] = Tools::inflateStripped($x['bytes']);
|
||||
$x['inflated'] = new Types\Bytes(Tools::inflateStripped($x['bytes']));
|
||||
}
|
||||
if (isset($this->callbacks[TLCallback::CONSTRUCTOR_CALLBACK][$x['_']])) {
|
||||
foreach ($this->callbacks[TLCallback::CONSTRUCTOR_CALLBACK][$x['_']] as $callback) {
|
||||
|
@ -9,6 +9,9 @@ use danog\MadelineProto\Lang;
|
||||
*/
|
||||
function mergeExtracted(): void
|
||||
{
|
||||
if (!\file_exists('extracted.json')) {
|
||||
return;
|
||||
}
|
||||
foreach (\json_decode(\file_get_contents('extracted.json'), true) as $key => $value) {
|
||||
$key = \preg_replace(['|flags\.\d+[?]|', '/Vector[<].*/'], ['', 'Vector t'], $key);
|
||||
$key = \str_replace('param_hash_type_int', 'param_hash_type_Vector t', $key);
|
||||
|
Loading…
Reference in New Issue
Block a user