mirror of
https://github.com/flibusta-apps/telegram_files_server.git
synced 2025-12-06 20:45:37 +01:00
Ignore teloxide::ApiError::MessageToForwardNotFound
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -11,6 +11,8 @@ __pycache__
|
|||||||
venv
|
venv
|
||||||
|
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
/target
|
/target
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ pub async fn upload_file(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn download_file(chat_id: i64, message_id: i32) -> Result<File, Box<dyn Error>> {
|
pub async fn download_file(chat_id: i64, message_id: i32) -> Result<Option<File>, Box<dyn Error>> {
|
||||||
let bot = ROUND_ROBIN_BOT.get_bot();
|
let bot = ROUND_ROBIN_BOT.get_bot();
|
||||||
|
|
||||||
let forwarded_message = match bot
|
let forwarded_message = match bot
|
||||||
@@ -82,6 +82,12 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Result<File, Box<dy
|
|||||||
{
|
{
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
if let teloxide::RequestError::Api(ref err) = err {
|
||||||
|
if let teloxide::ApiError::MessageToForwardNotFound = err {
|
||||||
|
return Ok(None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log::error!("Error: {}", err);
|
log::error!("Error: {}", err);
|
||||||
return Err(Box::new(err));
|
return Err(Box::new(err));
|
||||||
}
|
}
|
||||||
@@ -99,5 +105,5 @@ pub async fn download_file(chat_id: i64, message_id: i32) -> Result<File, Box<dy
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(File::open(path).await?)
|
Ok(Some(File::open(path).await?))
|
||||||
}
|
}
|
||||||
@@ -91,7 +91,12 @@ async fn upload(data: TypedMultipart<UploadFileRequest>) -> impl IntoResponse {
|
|||||||
|
|
||||||
async fn download(Path((chat_id, message_id)): Path<(i64, i32)>) -> impl IntoResponse {
|
async fn download(Path((chat_id, message_id)): Path<(i64, i32)>) -> impl IntoResponse {
|
||||||
let file = match download_file(chat_id, message_id).await {
|
let file = match download_file(chat_id, message_id).await {
|
||||||
Ok(v) => v,
|
Ok(v) => {
|
||||||
|
match v {
|
||||||
|
Some(v) => v,
|
||||||
|
None => return StatusCode::BAD_REQUEST.into_response(),
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
log::error!("{}", err);
|
log::error!("{}", err);
|
||||||
return StatusCode::BAD_REQUEST.into_response()
|
return StatusCode::BAD_REQUEST.into_response()
|
||||||
|
|||||||
Reference in New Issue
Block a user