···11use std::io::Cursor;
2233+use crate::advent::get_a_joke;
34use atrium_api::types::string::{Nsid, RecordKey};
45use atrium_crypto::keypair::P256Keypair;
55-use atrium_repo::{Repository, blockstore::{CarStore, MemoryBlockStore}};
66-use rand::seq::IndexedRandom;
66+use atrium_repo::{
77+ Repository,
88+ blockstore::{CarStore, MemoryBlockStore},
99+};
710use serde::Serialize;
811912const CHALLENGE_DID: &str = "did:plc:3oktyyf7u4ecnvdwf3ogehpd";
1010-1111-const VERY_BAD_JOKE_SETUPS: &[&str] = &[
1212- "what do you call a cow with two legs?",
1313- "what do bees do if they need a ride?",
1414- "what do you call a monkey that loves doritos?",
1515- "why did the can crusher quit her job?",
1616- "when’s the best time to go to the dentist?",
1717- "why do seagulls fly over the sea?",
1818- "what do you call a farm that makes bad jokes?",
1919- "why do fish live in saltwater?",
2020- "what kind of streets do ghosts haunt?",
2121- "what do you call it when one cow spies on another?",
2222- "what happens when a frog’s car breaks down?",
2323- "what does a zombie vegetarian eat?",
2424- "what do you call it when a snowman throws a tantrum?",
2525- "why did the scarecrow win an award?",
2626- "what did the buffalo say when his son left?",
2727- "wait, you don’t want to hear a joke about potassium?",
2828-];
29133014#[derive(Debug, thiserror::Error)]
3115pub enum CarBuildError {
···6650 // add record
6751 let key = format!("{}/{}", collection.as_str(), rkey.as_str());
6852 let created_at = &chrono::Utc::now().to_rfc3339();
6969- let joke = VERY_BAD_JOKE_SETUPS.choose(&mut rand::rng()).unwrap_or(&"no joke");
5353+ let joke = get_a_joke();
7054 let record = ChallengeRecord {
7155 created_at,
7256 verification_code,
+29
shared/src/advent/mod.rs
···88use handlebars::{Handlebars, RenderError};
99use markdown::{CompileOptions, Options};
1010use rand::distr::{Alphanumeric, SampleString};
1111+use rand::seq::IndexedRandom;
1112use rust_embed::EmbeddedFile;
1213use serde_json::json;
1314use sqlx::PgPool;
···438439439440 Ok(result)
440441}
442442+443443+const VERY_BAD_JOKE_SETUPS: &[&str] = &[
444444+ "what do you call a cow with two legs?",
445445+ "what do bees do if they need a ride?",
446446+ "what do you call a monkey that loves doritos?",
447447+ "why did the can crusher quit her job?",
448448+ "when’s the best time to go to the dentist?",
449449+ "why do seagulls fly over the sea?",
450450+ "what do you call a farm that makes bad jokes?",
451451+ "why do fish live in saltwater?",
452452+ "what kind of streets do ghosts haunt?",
453453+ "what do you call it when one cow spies on another?",
454454+ "what happens when a frog’s car breaks down?",
455455+ "what does a zombie vegetarian eat?",
456456+ "what do you call it when a snowman throws a tantrum?",
457457+ "why did the scarecrow win an award?",
458458+ "what did the buffalo say when his son left?",
459459+ "wait, you don’t want to hear a joke about potassium?",
460460+ "how do you organize a space party?",
461461+ "what did one casket say to the other casket?",
462462+];
463463+464464+/// Gets a random joke from the VERY_BAD_JOKE_SETUPS array
465465+pub fn get_a_joke() -> &'static str {
466466+ VERY_BAD_JOKE_SETUPS
467467+ .choose(&mut rand::rng())
468468+ .unwrap_or(&"no joke")
469469+}