mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 20:04:45 +01:00
Fix getMediaPreview
This commit is contained in:
parent
e63415a2ef
commit
1e31286e88
@ -415,23 +415,39 @@ class ApiExtensions
|
||||
}
|
||||
|
||||
$media = $message['media'][array_key_last($message['media'])];
|
||||
$thumb = null;
|
||||
switch (true) {
|
||||
case isset($media['sizes']):
|
||||
$thumb = $media['sizes'][array_key_last($media['sizes'])];
|
||||
foreach ($media['sizes'] as $size) {
|
||||
if ($size['_'] === 'photoSize') {
|
||||
$thumb = $size;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case isset($media['thumb']['size']):
|
||||
$thumb = $media['thumb'];
|
||||
break;
|
||||
case !empty($media['thumbs']):
|
||||
$thumb = $media['thumbs'][array_key_last($media['thumbs'])];
|
||||
foreach ($media['thumbs'] as $size) {
|
||||
if ($size['_'] === 'photoSize') {
|
||||
$thumb = $size;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case isset($media['photo']['sizes']):
|
||||
$thumb = $media['photo']['sizes'][array_key_last($media['photo']['sizes'])];
|
||||
foreach ($media['photo']['sizes'] as $size) {
|
||||
if ($size['_'] === 'photoSize') {
|
||||
$thumb = $size;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new UnexpectedValueException('Message has no preview');
|
||||
|
||||
}
|
||||
if (null === $thumb) {
|
||||
throw new UnexpectedValueException('Empty preview');
|
||||
}
|
||||
$info = yield $this->madelineProto->getDownloadInfo($thumb);
|
||||
|
||||
if ($media['_'] === 'webPage') {
|
||||
|
Loading…
Reference in New Issue
Block a user