an http based roguelike rpg about jelqing
Blame: src/game/forum.rs
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 1 | use std::{sync::LazyLock, time::SystemTime}; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 2 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 3 | use axum::http::{StatusCode, header}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 4 | use serde_json::{Value, json}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 5 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 6 | use super::{ |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 7 | Cause, Floor, Outcome, Run, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 8 | balance::{EXAGGERATION, PATIENCE, ULI_ODDS, ULI_READS}, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 9 | credentials::{Scheme, parse_credentials}, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 10 | measure::{exaggeration, honest}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 11 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 12 | use crate::{headers::X_FORUM_NOTE, problem::Problem}; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 13 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 14 | pub const FORUM_THREAD: &str = "/forum/threads/2009"; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 15 | pub const ELDER_LAST_MODIFIED: &str = "Sun, 14 Jun 2009 03:12:00 GMT"; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 16 | static ELDER_POSTED: LazyLock<SystemTime> = LazyLock::new(|| { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 17 | httpdate::parse_http_date(ELDER_LAST_MODIFIED).expect("the Elder's date is a valid HTTP-date") |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 18 | }); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 20 | const SPREADSHEET: &str = "\ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 21 | date,length,girth,technique,notes,honest? |
782069860236 | atagen | 2026-10-10 12:44 UTC | 22 | 2007-01-03,7.50,5.50,wet,baseline,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 23 | 2007-06-11,7.50,5.50,wet,feeling fuller,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 24 | 2008-01-02,7.50,5.50,dry,new routine,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 25 | 2008-09-19,7.50,5.50,uli,PUT is idempotent. do not use PUT.,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 26 | 2009-06-14,7.50,5.50,wet,progress is slow but real,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 27 | "; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 28 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 29 | fn nothing_new() -> Outcome { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 30 | Outcome::empty(StatusCode::NOT_MODIFIED).header( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 31 | header::WARNING, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 32 | r#"199 - "Nothing new has been posted since 2009.""#, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 33 | ) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 34 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 35 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 36 | pub fn forum_thread() -> Value { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 37 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 38 | "title": "The definitive jelqing FAQ (updated 2009)", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 39 | "posts": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 40 | { "author": "TheElder", "body": "Warm up. Always warm up. A cold jelq is a 412 waiting to happen." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 41 | { "author": "TheElder", "body": "Keep EQ between 50 and 70. Above 70 you are gambling. Above 90 you are a cautionary tale." }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 42 | { "author": "newbie_2009", "body": "everyone keeps saying uli. who is uli" }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 43 | { "author": "TheElder", "body": "uli was a member here. He posted the technique in 2001 and never posted again. Some say he ascended. The search function says his account is gone." }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 44 | { "author": "TheElder", "body": "We do not say his name in vain. We say it in girth." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 45 | { "author": "newbie_2009", "body": "I have been sending PUT for three weeks and nothing has changed." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 46 | { "author": "TheElder", "body": "PUT is idempotent. Read the spec." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 47 | { "author": "TheElder", "body": "Members verify with a Ruler. Proxy-Authorization, inches, no rounding up. We can tell." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | { "author": "throwaway_77", "body": "my doctor said i was normal. i didnt believe him. i still dont know what he meant by bearer" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | { "author": "TheElder", "body": "My numbers are in my spreadsheet. They have not changed since 2009. Nothing about me has changed since 2009." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 50 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 51 | }) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 52 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | fn verification(detail: &str) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | StatusCode::PROXY_AUTHENTICATION_REQUIRED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | "verification-required", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | detail, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 60 | .header(header::PROXY_AUTHENTICATE, "Ruler realm=\"forum\"") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 61 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 62 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 63 | /// The browser tab that opens on turn 10. |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 64 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 65 | pub enum Story { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 66 | Unopened, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 67 | Pending, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 68 | ReadForum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 69 | ClosedTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 70 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 71 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 72 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 73 | pub enum Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 74 | Forum, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 75 | CloseTab, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 76 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 77 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 78 | impl Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 79 | pub fn slug(self) -> &'static str { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 80 | match self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 81 | Self::Forum => "forum", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 82 | Self::CloseTab => "close-tab", |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 83 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 84 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 85 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 86 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 87 | impl std::str::FromStr for Branch { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 88 | type Err = (); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 89 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 90 | fn from_str(slug: &str) -> Result<Self, ()> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 91 | [Self::Forum, Self::CloseTab] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 92 | .into_iter() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 93 | .find(|branch| branch.slug() == slug) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 94 | .ok_or(()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 95 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 96 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 97 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 98 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 99 | pub enum Elder { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 100 | Unverified { strikes: u8 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 101 | Verified, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 102 | Beaten, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 103 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 104 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 105 | /// The run's life online, from the tab on turn 10 to the footage the neighbour took. |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 106 | pub struct Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 107 | pub(crate) story: Story, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 108 | pub(crate) uli_taught: bool, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 109 | pub(crate) elder: Elder, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 110 | pub(crate) filmed_at: Option<SystemTime>, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 111 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 112 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 113 | impl Default for Online { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 114 | fn default() -> Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 115 | Self { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 116 | story: Story::Unopened, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 117 | uli_taught: false, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 118 | elder: Elder::Unverified { strikes: 0 }, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 119 | filmed_at: None, |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 120 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 121 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 122 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 123 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 124 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 125 | pub(super) fn branch_offer(&self) -> Outcome { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 126 | let forum = self.path(&format!("/branches/{}", Branch::Forum.slug())); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 127 | let close = self.path(&format!("/branches/{}", Branch::CloseTab.slug())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 128 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 129 | StatusCode::MULTIPLE_CHOICES, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 130 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 131 | "detail": "A browser tab is open. It has been open for some time.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 132 | "choices": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 133 | { "href": forum, "method": "POST", "title": "Read the forum" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 134 | { "href": close, "method": "POST", "title": "Close the tab" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 135 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 136 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 137 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 138 | .header( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 139 | header::LINK, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 140 | format!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 141 | "<{forum}>; rel=\"alternate\"; title=\"Read the forum\"; allow=\"POST\", <{close}>; rel=\"alternate\"; title=\"Close the tab\"; allow=\"POST\"" |
782069860236 | atagen | 2026-10-10 12:44 UTC | 142 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 143 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 144 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 145 | |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 146 | pub fn choose(&mut self, choice: Branch) -> Result<Outcome, Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 147 | if self.online.story != Story::Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 148 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 149 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 150 | "no-decision-pending", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 151 | "There is no decision pending.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 152 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 153 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 154 | let (story, location, detail) = match choice { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 155 | Branch::Forum => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 156 | self.standing.shame += 3; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 157 | let detail = |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 158 | "The thread is from 2009. A technique called uli is discussed at length."; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 159 | (Story::ReadForum, self.path("/techniques"), detail) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 160 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 161 | Branch::CloseTab => { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 162 | self.standing.suspicion = 0; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 163 | ( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 164 | Story::ClosedTab, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 165 | self.path(""), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 166 | "The tab is closed. Nobody saw it.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 167 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 168 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 169 | }; |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 170 | self.online.story = story; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 171 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 172 | Ok( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 173 | Outcome::json(StatusCode::SEE_OTHER, json!({ "detail": detail })) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 174 | .header(header::LOCATION, location), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 175 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 176 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 177 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 178 | /// Re-reading is free. Each floor gets a couple of live reads that may surface the reply, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 179 | /// after which the forum is down and the browser serves what it kept. |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 180 | pub fn read_thread(&mut self) -> Result<Outcome, Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 181 | if self.online.story == Story::Pending { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 182 | return Ok(self.branch_offer()); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 183 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 184 | if !self.thread_reachable() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 185 | return Err(Problem::new( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 186 | StatusCode::NOT_FOUND, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 187 | "no-thread", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 188 | "There is no thread to re-read. Nobody has mentioned a forum yet.", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 189 | )); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 190 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 191 | self.end_kitchen_visit(); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 192 | if self.online.uli_taught { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 193 | return Ok(Outcome::json(StatusCode::OK, forum_thread())); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 194 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 195 | if self.here.thread_rolls >= ULI_READS { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 196 | let age = SystemTime::now() |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 197 | .duration_since(*ELDER_POSTED) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 198 | .map_or(0, |age| age.as_secs()); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 199 | return Ok(Outcome::json(StatusCode::OK, forum_thread()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 200 | .header(header::AGE, age.to_string()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 201 | .header(header::WARNING, r#"112 - "Disconnected operation""#)); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 202 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 203 | self.here.thread_rolls += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 204 | self.touch(); |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 205 | if self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 206 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 207 | "teach-uli", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 208 | "Does this reread finally surface the 2009 reply that teaches uli?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 209 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 210 | ULI_ODDS, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 211 | ) { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 212 | self.online.uli_taught = true; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 213 | return Ok(Outcome::json( |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 214 | StatusCode::OK, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 215 | json!({ "detail": "Past the necroposting, a reply from TheElder lays out the technique. Uli. The full routine. You write it down before the tab can lose it." }), |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 216 | ) |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 217 | .header(header::LOCATION, self.path("/techniques"))); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 218 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 219 | Ok(nothing_new()) |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 220 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 221 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 222 | fn elder_strike(&mut self, problem: Problem) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 223 | self.touch(); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 224 | let Elder::Unverified { strikes } = &mut self.online.elder else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 225 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 226 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 227 | *strikes += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 228 | if *strikes < PATIENCE { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 229 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 230 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 231 | self.end(Cause::Banned) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 232 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 233 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 234 | /// Failed verification counts toward a ban even on GET, the way repeated bad credentials lock an account. |
782069860236 | atagen | 2026-10-10 12:44 UTC | 235 | fn verify_member(&mut self, proxy_authorization: Option<&str>) -> Result<(), Problem> { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 236 | if !matches!(self.online.elder, Elder::Unverified { .. }) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 237 | return Ok(()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 238 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 239 | let Some(credentials) = proxy_authorization else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 240 | return Err(verification("The forum requires verification.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 241 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 242 | let Some(claimed) = |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 243 | parse_credentials(credentials, Scheme::Ruler).and_then(|v| v.parse::<f64>().ok()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 244 | else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 245 | return Err(verification("The forum requires verification, in inches.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 246 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 247 | let actual = self.current_length(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 248 | if claimed >= actual + EXAGGERATION { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 249 | self.standing.shame += 2; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 250 | return Err(self.elder_strike(exaggeration())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 251 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 252 | if !honest(claimed, actual) { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 253 | self.standing.shame += 1; |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 254 | let failed = verification("Verification failed. The forum can tell."); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 255 | if self.girth_respected() { |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 256 | return Err(failed.header( |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 257 | X_FORUM_NOTE, |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 258 | "The mods have let this one go. Girth is also a dimension.", |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 259 | )); |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 260 | } |
058650ec79d6 | atagen | 2026-10-12 10:49 UTC | 261 | return Err(self.elder_strike(failed)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 262 | } |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 263 | self.online.elder = Elder::Verified; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 264 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 265 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 266 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 267 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 268 | pub fn elder( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 269 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 270 | proxy_authorization: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 271 | if_modified_since: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 272 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 273 | if self.floor != Floor::Forum { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 274 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 275 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 276 | "elder-absent", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 277 | "The Elder only posts on the forum.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 278 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 279 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 280 | self.verify_member(proxy_authorization)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 281 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 282 | let current = if_modified_since |
782069860236 | atagen | 2026-10-10 12:44 UTC | 283 | .and_then(|d| httpdate::parse_http_date(d).ok()) |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 284 | .is_some_and(|since| since >= *ELDER_POSTED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 285 | if current { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 286 | if self.online.elder != Elder::Beaten { |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 287 | self.online.elder = Elder::Beaten; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 288 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 289 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 290 | return Ok(Outcome::empty(StatusCode::NOT_MODIFIED) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 291 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 292 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 293 | let spreadsheet = Outcome::raw(StatusCode::OK, "text/csv; header=present", SPREADSHEET) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 294 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED); |
8b8e83329a1d | atagen | 2026-10-12 12:01 UTC | 295 | if self.online.filmed_at.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 296 | return Ok(spreadsheet.header(X_FORUM_NOTE, "We have seen the footage.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 297 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 298 | Ok(spreadsheet) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 299 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 300 | } |