Add uploading messages
This commit is contained in:
parent
e5c9ff3aed
commit
d7a0a6a3e5
|
@ -618,6 +618,54 @@ pub async fn upload_worker(
|
||||||
} else {
|
} else {
|
||||||
format!("{}.part{:02}", &video_filename, i)
|
format!("{}.part{:02}", &video_filename, i)
|
||||||
};
|
};
|
||||||
|
let message = tclient
|
||||||
|
.send_message(
|
||||||
|
&chat,
|
||||||
|
InputMessage::text(&format!("Uploading {}...", &video_filename)),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
if let Err(ref err) = message {
|
||||||
|
eprintln!("Failed to send uploading message: {:?}", err);
|
||||||
|
let text = format!("{:#?}", err);
|
||||||
|
let size = text.len();
|
||||||
|
let mut stream = Cursor::new(text.into_bytes());
|
||||||
|
match tclient
|
||||||
|
.upload_stream(&mut stream, size, "failed-send-uploading.log".to_string())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(uploaded) => {
|
||||||
|
let message = InputMessage::text("Failed to send uploading message")
|
||||||
|
.mime_type("text/plain")
|
||||||
|
.file(uploaded);
|
||||||
|
if let Err(err) = tclient.send_message(&chat, message).await {
|
||||||
|
eprintln!(
|
||||||
|
"Failed to send message about failing to send uploading message: {:?}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
if let Err(err) = tclient.send_message(&chat, InputMessage::text("Failed to send message about failing to send uploading message, see logs")).await {
|
||||||
|
eprintln!("Failed to send message about failing to send message about failing to send uploading message: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!(
|
||||||
|
"Failed to upload logs about failing to send uploading message: {:?}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
if let Err(err) = tclient
|
||||||
|
.send_message(
|
||||||
|
&chat,
|
||||||
|
InputMessage::text(
|
||||||
|
"Failed to upload logs about failing to send uploading message, see logs",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
eprintln!("Failed to send message about failing to upload logs about failing to send uploading message: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
let mut size = file.stream_position().await.unwrap();
|
let mut size = file.stream_position().await.unwrap();
|
||||||
if size > 2000 * 1024 * 1024 {
|
if size > 2000 * 1024 * 1024 {
|
||||||
size = 2000 * 1024 * 1024;
|
size = 2000 * 1024 * 1024;
|
||||||
|
@ -663,6 +711,50 @@ pub async fn upload_worker(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if let Ok(mut message) = message {
|
||||||
|
if let Err(err) = message.delete().await {
|
||||||
|
eprintln!("Failed to delete uploading message: {:?}", err);
|
||||||
|
let text = format!("{:#?}", err);
|
||||||
|
let size = text.len();
|
||||||
|
let mut stream = Cursor::new(text.into_bytes());
|
||||||
|
match tclient
|
||||||
|
.upload_stream(&mut stream, size, "failed-delete-uploading.log".to_string())
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(uploaded) => {
|
||||||
|
let message = InputMessage::text("Failed to delete uploading message")
|
||||||
|
.mime_type("text/plain")
|
||||||
|
.file(uploaded);
|
||||||
|
if let Err(err) = tclient.send_message(&chat, message).await {
|
||||||
|
eprintln!(
|
||||||
|
"Failed to send message about failing to delete uploading message: {:?}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
if let Err(err) = tclient.send_message(&chat, InputMessage::text("Failed to send message about failing to delete uploading message, see logs")).await {
|
||||||
|
eprintln!("Failed to send message about failing to send message about failing to delete uploading message: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!(
|
||||||
|
"Failed to upload logs about failing to delete uploading message: {:?}",
|
||||||
|
err
|
||||||
|
);
|
||||||
|
if let Err(err) = tclient
|
||||||
|
.send_message(
|
||||||
|
&chat,
|
||||||
|
InputMessage::text(
|
||||||
|
"Failed to upload logs about failing to delete uploading message, see logs",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
eprintln!("Failed to send message about failing to upload logs about failing to delete uploading message: {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if success {
|
if success {
|
||||||
if let Err(err) = remove_file(&video_filename) {
|
if let Err(err) = remove_file(&video_filename) {
|
||||||
|
|
Loading…
Reference in New Issue