From 6a4cff16610b2eef69368d253152797929ed9dc2 Mon Sep 17 00:00:00 2001 From: Steven Vergenz <1882376+stevenvergenz@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:22:13 -0700 Subject: [PATCH] Rate limit => NotFound --- src/api/client_server/media.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/api/client_server/media.rs b/src/api/client_server/media.rs index f6022c3e..3897d83d 100644 --- a/src/api/client_server/media.rs +++ b/src/api/client_server/media.rs @@ -308,17 +308,18 @@ pub async fn get_media_preview_route( )); } - if let Ok(preview) = get_url_preview(&url).await { - let res = serde_json::value::to_raw_value(&preview).expect("Converting to JSON failed"); - return Ok(get_media_preview::v3::Response::from_raw_value(res)); - } - - Err(Error::BadRequest( - ErrorKind::LimitExceeded { - retry_after: Some(RetryAfter::Delay(Duration::from_secs(5))), + match get_url_preview(&url).await { + Ok(preview) => { + let res = serde_json::value::to_raw_value(&preview).expect("Converting to JSON failed"); + Ok(get_media_preview::v3::Response::from_raw_value(res)) }, - "Retry later", - )) + Err(_) => { + Err(Error::BadRequest( + ErrorKind::NotFound, + "Failed to find preview data", + )) + }, + } } /// # `POST /_matrix/media/r0/upload`