fix(client): incorrect parsing of video stickers as video
This commit is contained in:
parent
bc2ed98b14
commit
b0055b791c
1 changed files with 23 additions and 12 deletions
|
@ -12,6 +12,29 @@ export function parseDocument(
|
||||||
client: TelegramClient,
|
client: TelegramClient,
|
||||||
doc: tl.RawDocument
|
doc: tl.RawDocument
|
||||||
): RawDocument {
|
): RawDocument {
|
||||||
|
const stickerAttr = doc.attributes.find(
|
||||||
|
(a) =>
|
||||||
|
a._ === 'documentAttributeSticker' ||
|
||||||
|
a._ === 'documentAttributeCustomEmoji'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (stickerAttr) {
|
||||||
|
const sz = doc.attributes.find(
|
||||||
|
(it) =>
|
||||||
|
it._ === 'documentAttributeImageSize' ||
|
||||||
|
it._ === 'documentAttributeVideo'
|
||||||
|
)! as tl.RawDocumentAttributeImageSize | tl.RawDocumentAttributeVideo
|
||||||
|
|
||||||
|
return new Sticker(
|
||||||
|
client,
|
||||||
|
doc,
|
||||||
|
stickerAttr as
|
||||||
|
| tl.RawDocumentAttributeSticker
|
||||||
|
| tl.RawDocumentAttributeCustomEmoji,
|
||||||
|
sz
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
for (const attr of doc.attributes) {
|
for (const attr of doc.attributes) {
|
||||||
switch (attr._) {
|
switch (attr._) {
|
||||||
case 'documentAttributeAudio':
|
case 'documentAttributeAudio':
|
||||||
|
@ -20,18 +43,6 @@ export function parseDocument(
|
||||||
} else {
|
} else {
|
||||||
return new Audio(client, doc, attr)
|
return new Audio(client, doc, attr)
|
||||||
}
|
}
|
||||||
case 'documentAttributeSticker':
|
|
||||||
case 'documentAttributeCustomEmoji': {
|
|
||||||
const sz = doc.attributes.find(
|
|
||||||
(it) =>
|
|
||||||
it._ === 'documentAttributeImageSize' ||
|
|
||||||
it._ === 'documentAttributeVideo'
|
|
||||||
)! as
|
|
||||||
| tl.RawDocumentAttributeImageSize
|
|
||||||
| tl.RawDocumentAttributeVideo
|
|
||||||
|
|
||||||
return new Sticker(client, doc, attr, sz)
|
|
||||||
}
|
|
||||||
case 'documentAttributeVideo':
|
case 'documentAttributeVideo':
|
||||||
return new Video(client, doc, attr)
|
return new Video(client, doc, attr)
|
||||||
case 'documentAttributeImageSize':
|
case 'documentAttributeImageSize':
|
||||||
|
|
Loading…
Reference in a new issue