From 6d8e56db0d2bb5e2d6eaf7e6c3eb8ed82718a4c9 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Thu, 9 May 2024 03:02:00 +0200 Subject: [PATCH] made sure that the now being ready is a proper error message rather than being a silent error --- server/main-api/src/calendar/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/main-api/src/calendar/mod.rs b/server/main-api/src/calendar/mod.rs index 5ce31d5d0..70d0eb68e 100644 --- a/server/main-api/src/calendar/mod.rs +++ b/server/main-api/src/calendar/mod.rs @@ -41,6 +41,10 @@ pub async fn calendar_handler( } Ok(Some(loc)) => loc, }; + let Some(last_sync) = location.last_calendar_scrape_at else { + return HttpResponse::ServiceUnavailable() + .body("This calendar entry is currently in the process of being scraped, please try again later"); + }; let Some(calendar_url) = location.calendar_url else { return HttpResponse::NotFound() .content_type("text/plain") @@ -49,7 +53,7 @@ pub async fn calendar_handler( match get_from_db(&data.db, &id, &args.start_after, &args.end_before).await { Ok(events) => HttpResponse::Ok().json(models::Events { events, - last_sync: location.last_calendar_scrape_at.unwrap(), + last_sync, calendar_url, }), Err(e) => {