Skip to content

Commit

Permalink
Fix getDownloadLink
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Feb 9, 2024
1 parent 4345a18 commit 0e75a0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class API extends AbstractAPI
*
* @var string
*/
public const RELEASE = '8.0.0-beta190';
public const RELEASE = '8.0.0-beta191';
/**
* We're not logged in.
*
Expand Down
20 changes: 8 additions & 12 deletions src/MTProtoTools/FileServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,14 @@ public function getDownloadLink(array|string|Message|Media $media, ?string $scri
}

$messageMedia = $this->getDownloadInfo($media);
$messageMedia['size'] ??= $size;
$messageMedia['mime'] ??= $mime;
$messageMedia['name'] ??= $name;

$f = \is_string($media) ? $media : ($this->extractBotAPIFile($this->MTProtoToBotAPI($media))['file_id']);
[
'name' => $name,
'ext' => $ext,
'mime' => $mime,
'size' => $size,
] = $messageMedia;
$name = $name.$ext;
$size ??= $messageMedia['size'];
$mime ??= $messageMedia['mime'];
if (\is_string($media)) {
$f = $media;
} else {
$f = $this->extractBotAPIFile($this->MTProtoToBotAPI($media))['file_id'];
$name ??= $messageMedia['name'].$messageMedia['ext'];
}
}

return $scriptUrl."?".http_build_query([
Expand Down

0 comments on commit 0e75a0b

Please sign in to comment.