From deb506cb5298b33c42fe91e4dbd098dababf329d Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Thu, 5 Nov 2020 05:20:07 +0300 Subject: [PATCH] Add timestamps to images and videos It is already done for voice messages and makes saving attachments to one folder easier. --- src/mimefactory.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mimefactory.rs b/src/mimefactory.rs index 823e1e739..9e18696c7 100644 --- a/src/mimefactory.rs +++ b/src/mimefactory.rs @@ -1141,13 +1141,23 @@ async fn build_body_file( Viewtype::Image | Viewtype::Gif => format!( "{}.{}", if base_name.is_empty() { - "image" + chrono::Utc + .timestamp(msg.timestamp_sort as i64, 0) + .format("image_%Y-%m-%d_%H-%M-%S") + .to_string() } else { - base_name + base_name.to_string() }, &suffix, ), - Viewtype::Video => format!("video.{}", &suffix), + Viewtype::Video => format!( + "video_{}.{}", + chrono::Utc + .timestamp(msg.timestamp_sort as i64, 0) + .format("%Y-%m-%d_%H-%M-%S") + .to_string(), + &suffix + ), _ => blob.as_file_name().to_string(), };