fix: support Buffer/stream/path uploads in editMessageMedia (#1189)#1315
Open
yagop wants to merge 1 commit into
Open
fix: support Buffer/stream/path uploads in editMessageMedia (#1189)#1315yagop wants to merge 1 commit into
yagop wants to merge 1 commit into
Conversation
editMessageMedia only uploaded a new file when `media` was given as `attach://<local-path>`; a Buffer, stream, or plain local path was unsupported, and secondary fields (thumbnail/cover) were string-only. Route `media` through the same `_buildMediaItems` pipeline as sendMediaGroup so the primary media and its thumbnail/cover accept a Buffer / stream / local path (uploaded via an `attach://` part) or a file_id / URL string (passed through). Non-breaking: string callers and the legacy `attach://<local-path>` form are unchanged. Refs #1189 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
editMessageMediacould only upload a new file whenmediawas passed asattach://<local-path>. A Buffer / stream, or even a plain local path, was unsupported (the field was typedstring), and the secondary fields (thumbnail/cover) were string-only. Every other send method accepts a Buffer/stream/path, so this was an inconsistency.Refs #1189
Fix
Route
mediathrough the same_buildMediaItemspipeline used bysendMediaGroup/sendPaidMedia:mediaand itsthumbnail/covernow accept a Buffer / stream / local path (uploaded as anattach://multipart part) or a file_id / URL string (passed through).mediais widened fromInputMediatoUploadable<InputMedia>(the existing helper that widens file fields toInputFile)._buildMediaItems's parameter type is broadened to also acceptUploadable<InputMedia>.Non-breaking
stringcallers are unaffected (stringis assignable toInputFile).attach://<local-path>form is still accepted (the prefix is stripped and the path uploaded).file_id/ URL callers still produce a urlencoded body (no multipart).Tests / verification
npm run typecheckclean;npm run buildclean.test/unit/telegram.test.ts): 45/45 pass, incl. 3 new (Buffer ->attach://0_media; videothumbnailBuffer ->attach://0_thumbnail; file_id -> urlencoded passthrough).editMessageMediascoped run = 3/3 pass (attach:// path, Buffer upload, file_id with caption + reply_markup).doc/api.md; corrected a now-stalesendMediaGroupdoc comment that claimed editMessageMedia's secondary fields were string-only.🤖 Generated with Claude Code