diff --git a/no-image.jpg b/no-image.jpg new file mode 100644 index 0000000..6bf811b Binary files /dev/null and b/no-image.jpg differ diff --git a/src/MadelineProtoExtensions/ApiExtensions.php b/src/MadelineProtoExtensions/ApiExtensions.php index 21b6618..2c73fa6 100644 --- a/src/MadelineProtoExtensions/ApiExtensions.php +++ b/src/MadelineProtoExtensions/ApiExtensions.php @@ -4,6 +4,7 @@ namespace TelegramApiServer\MadelineProtoExtensions; +use Amp\ByteStream\ResourceInputStream; use Amp\Delayed; use Amp\Http\Server\FormParser\StreamedField; use Amp\Http\Server\Request; @@ -429,7 +430,15 @@ class ApiExtensions $thumb = $media['photo']['sizes'][array_key_last($media['photo']['sizes'])]; break; 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);