diff --git a/shared/challenges_markdown/five/part_one.md b/shared/challenges_markdown/five/part_one.md new file mode 100644 index 0000000..640ea85 --- /dev/null +++ b/shared/challenges_markdown/five/part_one.md @@ -0,0 +1,2 @@ +Day five is a only one part one. We talk about jetstream/firehose. A secret account creates a record and they have to +watch create/update to capture the verification code. We hav an added button when clicked it creates the record. \ No newline at end of file diff --git a/shared/challenges_markdown/four/part_one.md b/shared/challenges_markdown/four/part_one.md new file mode 100644 index 0000000..e40c5c2 --- /dev/null +++ b/shared/challenges_markdown/four/part_one.md @@ -0,0 +1 @@ +Day four is the first one is create a tid from a given clock id and date time (random id and time the event started?) \ No newline at end of file diff --git a/shared/challenges_markdown/four/part_two.md b/shared/challenges_markdown/four/part_two.md new file mode 100644 index 0000000..cbeaeec --- /dev/null +++ b/shared/challenges_markdown/four/part_two.md @@ -0,0 +1,2 @@ +This will be creating a new did, may end up being a only one part day if this is too difficult. I think it would be we +give them a genis did doc and they give us the did? \ No newline at end of file diff --git a/shared/challenges_markdown/six/part_one.md b/shared/challenges_markdown/six/part_one.md new file mode 100644 index 0000000..3038ede --- /dev/null +++ b/shared/challenges_markdown/six/part_one.md @@ -0,0 +1 @@ +Day six is about XRPC. First up is we have them create an LXM jwt. We validate it's for the correct lxm and did. \ No newline at end of file diff --git a/shared/challenges_markdown/six/part_two.md b/shared/challenges_markdown/six/part_two.md new file mode 100644 index 0000000..827482d --- /dev/null +++ b/shared/challenges_markdown/six/part_two.md @@ -0,0 +1 @@ +Part 2 is them making an xrpc request and if set properly we give them the day. \ No newline at end of file diff --git a/shared/challenges_markdown/three/part_one.md b/shared/challenges_markdown/three/part_one.md index 0ddd72c..1de2758 100644 --- a/shared/challenges_markdown/three/part_one.md +++ b/shared/challenges_markdown/three/part_one.md @@ -1,5 +1,3 @@ -Great job beating Part 1! Now onto Part 2. - -Keeping it simple proof of concept, blah, blah will have a real one here another time. Add a new field `partTwo` to the -record with the value `{{code}}` - \ No newline at end of file +This will be explaing the car format and will have a download link to a car file we create that they can download. +We can create a new web handler like. /day/3/{did} and it downloads the car file. +Inside the car export is just one record with the verficiation code \ No newline at end of file diff --git a/shared/challenges_markdown/three/part_two.md b/shared/challenges_markdown/three/part_two.md new file mode 100644 index 0000000..f19b62f --- /dev/null +++ b/shared/challenges_markdown/three/part_two.md @@ -0,0 +1,2 @@ +This will be them creating a car export with one collection in it and it holds the verification code. We tell them the +collection, rkey, and code to place in it \ No newline at end of file diff --git a/shared/src/advent/challenges/day_five.rs b/shared/src/advent/challenges/day_five.rs new file mode 100644 index 0000000..ca5fd79 --- /dev/null +++ b/shared/src/advent/challenges/day_five.rs @@ -0,0 +1,37 @@ +use crate::OAuthAgentType; +use crate::advent::day::Day; +use crate::advent::{AdventChallenge, AdventError, ChallengeCheckResponse}; +use async_trait::async_trait; +use sqlx::PgPool; + +pub struct DayFive { + pub pool: PgPool, + pub oauth_client: Option, +} + +#[async_trait] +impl AdventChallenge for DayFive { + fn pool(&self) -> &PgPool { + &self.pool + } + + fn day(&self) -> Day { + Day::Five + } + + fn has_part_two(&self) -> bool { + false + } + + fn requires_manual_verification_part_one(&self) -> bool { + true + } + + async fn check_part_one( + &self, + _did: String, + _verification_code: Option, + ) -> Result { + todo!() + } +} diff --git a/shared/src/advent/challenges/day_four.rs b/shared/src/advent/challenges/day_four.rs new file mode 100644 index 0000000..b9b8167 --- /dev/null +++ b/shared/src/advent/challenges/day_four.rs @@ -0,0 +1,37 @@ +use crate::OAuthAgentType; +use crate::advent::day::Day; +use crate::advent::{AdventChallenge, AdventError, ChallengeCheckResponse}; +use async_trait::async_trait; +use sqlx::PgPool; + +pub struct DayFour { + pub pool: PgPool, + pub oauth_client: Option, +} + +#[async_trait] +impl AdventChallenge for DayFour { + fn pool(&self) -> &PgPool { + &self.pool + } + + fn day(&self) -> Day { + Day::Four + } + + fn has_part_two(&self) -> bool { + false + } + + fn requires_manual_verification_part_one(&self) -> bool { + true + } + + async fn check_part_one( + &self, + _did: String, + _verification_code: Option, + ) -> Result { + todo!() + } +} diff --git a/shared/src/advent/challenges/day_six.rs b/shared/src/advent/challenges/day_six.rs new file mode 100644 index 0000000..210ba78 --- /dev/null +++ b/shared/src/advent/challenges/day_six.rs @@ -0,0 +1,37 @@ +use crate::OAuthAgentType; +use crate::advent::day::Day; +use crate::advent::{AdventChallenge, AdventError, ChallengeCheckResponse}; +use async_trait::async_trait; +use sqlx::PgPool; + +pub struct DaySix { + pub pool: PgPool, + pub oauth_client: Option, +} + +#[async_trait] +impl AdventChallenge for DaySix { + fn pool(&self) -> &PgPool { + &self.pool + } + + fn day(&self) -> Day { + Day::Five + } + + fn has_part_two(&self) -> bool { + false + } + + fn requires_manual_verification_part_one(&self) -> bool { + true + } + + async fn check_part_one( + &self, + _did: String, + _verification_code: Option, + ) -> Result { + todo!() + } +} diff --git a/shared/src/advent/challenges/mod.rs b/shared/src/advent/challenges/mod.rs index b247e8a..bbea308 100644 --- a/shared/src/advent/challenges/mod.rs +++ b/shared/src/advent/challenges/mod.rs @@ -1,3 +1,6 @@ +pub mod day_five; +pub mod day_four; pub mod day_one; +pub mod day_six; pub mod day_three; pub mod day_two; diff --git a/web/src/handlers/day.rs b/web/src/handlers/day.rs index c4b3845..cf04ce0 100644 --- a/web/src/handlers/day.rs +++ b/web/src/handlers/day.rs @@ -8,6 +8,9 @@ use axum::{ http::StatusCode, response::{IntoResponse, Redirect, Response}, }; +use shared::advent::challenges::day_five::DayFive; +use shared::advent::challenges::day_four::DayFour; +use shared::advent::challenges::day_six::DaySix; use shared::{ OAuthAgentType, OAuthClientType, advent::ChallengeCheckResponse, @@ -40,6 +43,18 @@ fn pick_day( pool: state.postgres_pool, oauth_client, })), + Day::Four => Ok(Box::new(DayFour { + pool: state.postgres_pool, + oauth_client, + })), + Day::Five => Ok(Box::new(DayFive { + pool: state.postgres_pool, + oauth_client, + })), + Day::Six => Ok(Box::new(DaySix { + pool: state.postgres_pool, + oauth_client, + })), _ => Err(AdventError::InvalidDay(0)), // Day::Three => {} // Day::Four => {} // Day::Five => {} @@ -124,7 +139,10 @@ pub async fn view_day_handler( .unwrap_or_else(|_| "Error loading part one".to_string()) } Some(code) => challenge - .markdown_text_part_one(Some(code), current_challenge.additional_context.as_ref()) + .markdown_text_part_one( + Some(code), + current_challenge.additional_context.as_ref(), + ) .map(|s| s.to_string()) .unwrap_or_else(|_| "Error loading part one".to_string()), }, @@ -224,7 +242,11 @@ async fn get_part_two_text( .start_challenge(users_did.to_string(), AdventPart::Two) .await .unwrap(); - let started = challenge.get_days_challenge(&users_did).await.ok().flatten(); + let started = challenge + .get_days_challenge(&users_did) + .await + .ok() + .flatten(); let ctx = started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_two(Some(new_code), ctx) @@ -243,15 +265,23 @@ async fn get_part_two_text( .start_challenge(users_did.to_string(), AdventPart::Two) .await .unwrap(); - let started = challenge.get_days_challenge(&users_did).await.ok().flatten(); - let ctx = started.as_ref().and_then(|c| c.additional_context.as_ref()); + let started = challenge + .get_days_challenge(&users_did) + .await + .ok() + .flatten(); + let ctx = + started.as_ref().and_then(|c| c.additional_context.as_ref()); challenge .markdown_text_part_two(Some(new_code), ctx) .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None) } Some(code) => challenge - .markdown_text_part_two(Some(code), current_challenge.additional_context.as_ref()) + .markdown_text_part_two( + Some(code), + current_challenge.additional_context.as_ref(), + ) .map(|opt| opt.map(|s| s.to_string())) .unwrap_or(None), }