mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-07 01:32:13 +00:00
feat(upload): give videos and animations Telegram's real 50 MB cap
One MAX_UPLOAD_BYTES (10 MiB) bounded every upload, but that is the *photo* limit: Telegram's own docs say sendVideo/sendAnimation/sendDocument take up to 50 MB, and RequestEntityTooLarge is "larger than 50 MB". So a 10-50 MB video that Telegram refused to fetch by URL was refused a download too, and a video has no smaller variant — the post was lost. The non-photo cap is now MAX_MEDIA_UPLOAD_BYTES, and such a body charges the process-wide budget for the length of the preparation (one 64 MiB unit covers the cap), since PREP_SLOTS alone no longer bounds their added RAM. A const test pins both caps against Telegram's numbers.
This commit is contained in:
@@ -709,6 +709,17 @@ mod tests {
|
||||
use std::time::Duration;
|
||||
use teloxide::ApiError;
|
||||
|
||||
/// The two multipart upload caps, pinned where the bot draws them: photos
|
||||
/// are the 10 MiB case, everything else the 50 MB one. A single cap for
|
||||
/// both refused to download a 10–50 MB video that Telegram would have
|
||||
/// accepted (and a video has no smaller variant to fall back to).
|
||||
#[test]
|
||||
fn upload_caps_match_telegrams_limits() {
|
||||
const { assert!(crate::photo::MAX_UPLOAD_BYTES == 10 * 1024 * 1024) };
|
||||
const { assert!(super::upload::MAX_MEDIA_UPLOAD_BYTES == 50 * 1024 * 1024) };
|
||||
const { assert!(crate::photo::MAX_PHOTO_DOWNLOAD_BYTES <= crate::photo::MAX_DECODE_BYTES) };
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn oversized_photo_boundary() {
|
||||
// The empirical Telegram limit: sum 10000 passes, 10001 fails. Pinned
|
||||
|
||||
Reference in New Issue
Block a user