Accept documents in media message ingestion

This commit is contained in:
TheGeneralist 2026-02-16 15:00:10 +01:00
parent 31f6beb161
commit 16e938e756
Signed by: thegeneralist01
SSH key fingerprint: SHA256:pp9qddbCNmVNoSjevdvQvM5z0DHN7LTa8qBMbcMq/R4

View file

@ -587,20 +587,6 @@ async fn handle_media_message(
if let Some(document) = msg.document() {
let mime = document.mime_type.as_ref().map(|m| m.essence_str());
let is_media = if let Some(mime) = mime {
mime.starts_with("image/") || mime.starts_with("video/")
} else {
document
.file_name
.as_deref()
.and_then(|name| Path::new(name).extension().and_then(|ext| ext.to_str()))
.map(|ext| matches!(
ext.to_ascii_lowercase().as_str(),
"png" | "jpg" | "jpeg" | "gif" | "webp" | "bmp" | "mp4" | "mov" | "mkv"
))
.unwrap_or(false)
};
if is_media {
fs::create_dir_all(&media_dir)
.with_context(|| format!("create media dir {}", media_dir.display()))?;
let ext = mime.and_then(extension_from_mime);
@ -615,7 +601,6 @@ async fn handle_media_message(
handle_single_item(bot.clone(), chat_id, state.clone(), &entry_text, Some(msg.id)).await?;
return Ok(true);
}
}
if let Some(video) = msg.video() {
fs::create_dir_all(&media_dir)