diff --git a/shared/challenges_markdown/two/part_one.md b/shared/challenges_markdown/two/part_one.md index 851d156..d810f11 100644 --- a/shared/challenges_markdown/two/part_one.md +++ b/shared/challenges_markdown/two/part_one.md @@ -29,12 +29,3 @@ This uri can be broken down into 3 parts: Using what you learned from day 1 find the following record `{{at_uri}}` and enter the verification code found in the record for it below - -```json -{ - "$type": "codes.advent.challenge.day", - "partOne": "{{code}}" -} -``` - -[//]: # () \ No newline at end of file diff --git a/shared/src/advent/challenges/day_two.rs b/shared/src/advent/challenges/day_two.rs index 753e6ff..8e0a157 100644 --- a/shared/src/advent/challenges/day_two.rs +++ b/shared/src/advent/challenges/day_two.rs @@ -29,6 +29,10 @@ impl AdventChallenge for DayTwo { true } + fn requires_manual_verification_part_one(&self) -> bool { + true + } + /// Create a record via the challenge agent and return the at_uri as additional context async fn build_additional_context( &self, @@ -57,9 +61,6 @@ impl AdventChallenge for DayTwo { let known_record: KnownRecord = record_data.into(); let record_value: atrium_api::types::Unknown = known_record.into(); - // Use a unique rkey per user based on the did to avoid collisions - // let rkey = did.replace(":", "_").replace(".", "_"); - let create_record_result = agent .api .com @@ -93,71 +94,37 @@ impl AdventChallenge for DayTwo { async fn check_part_one( &self, did: String, - _verification_code: Option, + verification_code: Option, ) -> Result { - let client = self - .oauth_client - .as_ref() - .ok_or(AdventError::ShouldNotHappen( - "No oauth client. This should not happen".to_string(), - ))?; - - let record_res = client - .api - .com - .atproto - .repo - .get_record( - atrium_api::com::atproto::repo::get_record::ParametersData { - cid: None, - collection: advent::challenge::Day::NSID.parse().unwrap(), - repo: did.parse().unwrap(), - rkey: "1".parse().unwrap(), - } - .into(), - ) - .await; - - let record = match record_res { - Ok(r) => r, - Err(e) => { - log::error!("Error getting record: {}", e); - return Ok(ChallengeCheckResponse::Incorrect("Does not appear to be a record in your repo in the collection codes.advent.challenge.day with the record key of 1".to_string())); + let submitted_code = match verification_code { + Some(code) if !code.is_empty() => code, + _ => { + return Ok(ChallengeCheckResponse::Incorrect( + "Please enter a verification code".to_string(), + )); } }; let Some(challenge) = self.get_days_challenge(&did).await? else { - log::error!("Could not find a challenge record for day: 1 for the user: {did:?}"); + log::error!("Could not find a challenge record for day: 2 for the user: {did:?}"); return Err(AdventError::ShouldNotHappen( "Could not find challenge record".to_string(), )); }; - let record_data = match safe_check_unknown_record_parse::( - record.value.clone(), - ) { - Ok(rd) => rd, - Err(e) => { - log::error!("Error parsing record: {e}"); - return Ok(ChallengeCheckResponse::Incorrect(format!( - "There is a record at the correct location, but it does not seem like it is correct. Try again:\n{e}" - ))); - } - }; - - let verification_code = + let expected_code = challenge .verification_code_one .ok_or(AdventError::ShouldNotHappen( - "no verification code for day 1 challenge :/".to_string(), + "no verification code for day 2 challenge".to_string(), ))?; - Ok(if record_data.part_one == verification_code { + Ok(if submitted_code == expected_code { ChallengeCheckResponse::Correct } else { ChallengeCheckResponse::Incorrect(format!( "The code {} is incorrect", - record_data.part_one + submitted_code )) }) } diff --git a/web/templates/index.askama.html b/web/templates/index.askama.html index 66cd83d..e32e6da 100644 --- a/web/templates/index.askama.html +++ b/web/templates/index.askama.html @@ -3,8 +3,8 @@ {% block content %}
-

Welcome to AT Protocol Advent! 🎄

-

Complete daily challenges throughout December to learn about the AT Protocol.

+

Welcome to atproto advent! 🎄

+

Complete daily challenges throughout December March 27th to learn about the atprotocol.

@@ -24,7 +24,7 @@