Add image for default preview.

This commit is contained in:
Alexander Pankratov 2020-08-16 00:12:17 +03:00
parent 56dd60b474
commit 1deff5ac24
2 changed files with 10 additions and 1 deletions

BIN
no-image.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -4,6 +4,7 @@
namespace TelegramApiServer\MadelineProtoExtensions; namespace TelegramApiServer\MadelineProtoExtensions;
use Amp\ByteStream\ResourceInputStream;
use Amp\Delayed; use Amp\Delayed;
use Amp\Http\Server\FormParser\StreamedField; use Amp\Http\Server\FormParser\StreamedField;
use Amp\Http\Server\Request; use Amp\Http\Server\Request;
@ -429,7 +430,15 @@ class ApiExtensions
$thumb = $media['photo']['sizes'][array_key_last($media['photo']['sizes'])]; $thumb = $media['photo']['sizes'][array_key_last($media['photo']['sizes'])];
break; break;
default: default:
throw new UnexpectedValueException('Message has no preview'); $stream = fopen(ROOT_DIR . '/no-image.jpg', 'rb');
return new Response(
200,
[
'Content-Type' => 'image/jpeg',
'Content-Length'=> fstat($stream)['size'],
],
new ResourceInputStream($stream)
);
} }
$info = yield $this->madelineProto->getDownloadInfo($thumb); $info = yield $this->madelineProto->getDownloadInfo($thumb);