mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 04:48:06 +00:00
Fix deserialization for bare Vectors
This commit is contained in:
parent
7b6d71753d
commit
3eaba9d2f4
@ -25,11 +25,21 @@ from ..object import Object
|
||||
class Vector(Object):
|
||||
ID = 0x1cb5c415
|
||||
|
||||
# Method added to handle the special case when a query returns a bare Vector (of Ints);
|
||||
# i.e., RpcResult body starts with 0x1cb5c415 (Vector Id) - e.g., messages.GetMessagesViews.
|
||||
@staticmethod
|
||||
def _read(b: BytesIO) -> Object or int:
|
||||
try:
|
||||
return Object.read(b)
|
||||
except KeyError:
|
||||
b.seek(-4, 1)
|
||||
return Int.read(b)
|
||||
|
||||
@staticmethod
|
||||
def read(b: BytesIO, t: Object = None) -> list:
|
||||
return [
|
||||
t.read(b) if t
|
||||
else Object.read(b)
|
||||
else Vector._read(b)
|
||||
for _ in range(Int.read(b))
|
||||
]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user