feat(telegram): capture document/file uploads #28
No reviewers
Labels
No labels
in-review
ready-for-agent
ready-for-human
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
weiwen/evie!28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "sandcastle/issue-24"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed and why
Implements issue #24: evie's Telegram handler now accepts documents and file uploads, not just photos and plain text.
Key changes
Extraction::Contentwith the file path embedded in the turn text.image/*) are additionally base64-encoded and passed as inlineImageContentso pi can inspect them visually, consistent with howmsg.photo()is handled.[Document file: /path]reference only.MAX_DOCUMENT_SIZE_BYTES) matching the Telegram Bot APIgetFilelimit; the bot replies "File too large" and bails out cleanly instead of failing silently.Option<(String, Vec<ImageContent>, Option<NamedTempFile>)>return fromextract_message_contentwith anExtractionenum (Content,FileTooLarge,Unhandled) to make the error case explicit.NamedTempFileguard with aTempGuardenum (File/Dir) — documents need aTempDirso the file keeps its original name inside it; photos still useNamedTempFile.sanitize_filename()strips any directory component from the Telegram-supplied filename to prevent path traversal before constructing the temp path.attachment_text()consolidates the caption + path formatting used by both photo and document branches (extracted in the follow-up refactor commit).ImageContent::with_mime_type()constructor so image documents can carry their actual MIME type instead of always hardcodingimage/jpeg.Decisions worth noting
TempGuard::Dirfor the full pi turn because dropping theTempDirwould delete the directory and invalidate the path reference handed to pi.Reviewer checklist
TempGuardlifetime: the guard is held in_temp_guardinhandle_message, which is dropped after the pi call returns — confirm that's the right scope.doc.file.sizeis au32in teloxide; the constant is alsou32, so no truncation.sanitize_filenameedge-case tests pass (empty,.,.., absolute paths, traversal).Closes #24