diff --git a/shared/src/advent/mod.rs b/shared/src/advent/mod.rs index f31874d..1ba10f2 100644 --- a/shared/src/advent/mod.rs +++ b/shared/src/advent/mod.rs @@ -140,7 +140,7 @@ pub trait AdventChallenge { } /// The text Markdown for challenge 1 - fn markdown_text_part_one( + async fn markdown_text_part_one( &self, verification_code: Option, additional_context: Option<&serde_json::Value>, @@ -176,7 +176,7 @@ pub trait AdventChallenge { } /// The text Markdown for challenge 2, could be None - fn markdown_text_part_two( + async fn markdown_text_part_two( &self, verification_code: Option, additional_context: Option<&serde_json::Value>, diff --git a/web/src/handlers/day.rs b/web/src/handlers/day.rs index 13d6587..a3320a5 100644 --- a/web/src/handlers/day.rs +++ b/web/src/handlers/day.rs @@ -109,6 +109,7 @@ pub async fn view_day_handler( let part_one_text = match did_clone { None => challenge .markdown_text_part_one(None, None) + .await .map(|s| s.to_string()) .unwrap_or_else(|_| "Error loading part one".to_string()), Some(ref users_did) => match challenge.get_days_challenge(&users_did).await { @@ -122,6 +123,7 @@ pub async fn view_day_handler( let ctx = started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_one(Some(new_code), ctx) + .await .map(|s| s.to_string()) .unwrap_or_else(|_| "Error loading part one".to_string()) } @@ -135,6 +137,7 @@ pub async fn view_day_handler( let ctx = started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_one(Some(new_code), ctx) + .await .map(|s| s.to_string()) .unwrap_or_else(|_| "Error loading part one".to_string()) } @@ -143,6 +146,7 @@ pub async fn view_day_handler( Some(code), current_challenge.additional_context.as_ref(), ) + .await .map(|s| s.to_string()) .unwrap_or_else(|_| "Error loading part one".to_string()), }, @@ -232,6 +236,7 @@ async fn get_part_two_text( let part_two_text: Option = match did_clone { None => challenge .markdown_text_part_two(None, None) + .await .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None), Some(users_did) => match challenge.get_days_challenge(&users_did).await { @@ -250,6 +255,7 @@ async fn get_part_two_text( let ctx = started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_two(Some(new_code), ctx) + .await .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None) } else { @@ -274,6 +280,7 @@ async fn get_part_two_text( started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_two(Some(new_code), ctx) + .await .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None) } @@ -282,6 +289,7 @@ async fn get_part_two_text( Some(code), current_challenge.additional_context.as_ref(), ) + .await .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None), }