an http based roguelike rpg about jelqing
Blame: src/game/forum.rs
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 1 | use std::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::{ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 7 | Cause, Elder, Floor, Outcome, Run, Story, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 8 | balance::{EXAGGERATION, PATIENCE, ULI_ODDS, ULI_READS}, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 9 | body::exaggeration, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 10 | honest, parse_credentials, |
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"; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 16 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 17 | const SPREADSHEET: &str = "\ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 18 | date,length,girth,technique,notes,honest? |
782069860236 | atagen | 2026-10-10 12:44 UTC | 19 | 2007-01-03,7.50,5.50,wet,baseline,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 20 | 2007-06-11,7.50,5.50,wet,feeling fuller,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 21 | 2008-01-02,7.50,5.50,dry,new routine,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 22 | 2008-09-19,7.50,5.50,uli,PUT is idempotent. do not use PUT.,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 23 | 2009-06-14,7.50,5.50,wet,progress is slow but real,no |
782069860236 | atagen | 2026-10-10 12:44 UTC | 24 | "; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 25 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 26 | fn nothing_new() -> Outcome { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 27 | Outcome::empty(StatusCode::NOT_MODIFIED).header( |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 28 | header::WARNING, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 29 | r#"199 - "Nothing new has been posted since 2009.""#, |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 30 | ) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 31 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 32 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 33 | pub fn forum_thread() -> Value { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 34 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 35 | "title": "The definitive jelqing FAQ (updated 2009)", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 36 | "posts": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 37 | { "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 | 38 | { "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 | 39 | { "author": "newbie_2009", "body": "everyone keeps saying uli. who is uli" }, |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 40 | { "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 | 41 | { "author": "TheElder", "body": "We do not say his name in vain. We say it in girth." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 42 | { "author": "newbie_2009", "body": "I have been sending PUT for three weeks and nothing has changed." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 43 | { "author": "TheElder", "body": "PUT is idempotent. Read the spec." }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 44 | { "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 | 45 | { "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 | 46 | { "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 | 47 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 48 | }) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 49 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 50 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 51 | fn verification(detail: &str) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 52 | Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 53 | StatusCode::PROXY_AUTHENTICATION_REQUIRED, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 54 | "verification-required", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 55 | detail, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 56 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 57 | .header(header::PROXY_AUTHENTICATE, "Ruler realm=\"forum\"") |
782069860236 | atagen | 2026-10-10 12:44 UTC | 58 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 59 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 60 | impl Run { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 61 | pub(super) fn branch_offer(&self) -> Outcome { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 62 | let forum = self.path("/branches/forum"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 63 | let close = self.path("/branches/close-tab"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 64 | Outcome::json( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 65 | StatusCode::MULTIPLE_CHOICES, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 66 | json!({ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 67 | "detail": "A browser tab is open. It has been open for some time.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 68 | "choices": [ |
782069860236 | atagen | 2026-10-10 12:44 UTC | 69 | { "href": forum, "method": "POST", "title": "Read the forum" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 70 | { "href": close, "method": "POST", "title": "Close the tab" }, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 71 | ], |
782069860236 | atagen | 2026-10-10 12:44 UTC | 72 | }), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 73 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 74 | .header( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 75 | header::LINK, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 76 | format!( |
d46f9d0b953a | atagen | 2026-10-10 14:41 UTC | 77 | "<{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 | 78 | ), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 79 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 80 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 81 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 82 | pub fn choose(&mut self, choice: &str) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 83 | if self.story != Story::Pending { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 84 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 85 | StatusCode::CONFLICT, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 86 | "no-decision-pending", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 87 | "There is no decision pending.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 88 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 89 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 90 | let (story, location, detail) = match choice { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 91 | "forum" => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 92 | self.shame += 3; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 93 | let detail = |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 94 | "The thread is from 2009. A technique called uli is discussed at length."; |
0fdc47364c8c | atagen | 2026-10-11 04:45 UTC | 95 | (Story::ReadForum, self.path("/techniques"), detail) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 96 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 97 | "close-tab" => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 98 | self.suspicion = 0; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 99 | ( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 100 | Story::ClosedTab, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 101 | self.path(""), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 102 | "The tab is closed. Nobody saw it.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 103 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 104 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 105 | _ => { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 106 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 107 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 108 | "no-such-choice", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 109 | "That was not one of the choices.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 110 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 111 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 112 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 113 | self.story = story; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 114 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 115 | Ok( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 116 | Outcome::json(StatusCode::SEE_OTHER, json!({ "detail": detail })) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 117 | .header(header::LOCATION, location), |
782069860236 | atagen | 2026-10-10 12:44 UTC | 118 | ) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 119 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 120 | |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 121 | /// 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 | 122 | /// after which the forum is down and the browser serves what it kept. |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 123 | pub fn read_thread(&mut self) -> Result<Outcome, Problem> { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 124 | if self.story == Story::Pending { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 125 | return Ok(self.branch_offer()); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 126 | } |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 127 | if !self.thread_reachable() { |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 128 | return Err(Problem::new( |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 129 | StatusCode::NOT_FOUND, |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 130 | "no-thread", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 131 | "There is no thread to re-read. Nobody has mentioned a forum yet.", |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 132 | )); |
e807266c323b | atagen | 2026-10-12 09:46 UTC | 133 | } |
5cc6ab966f30 | atagen | 2026-10-11 11:23 UTC | 134 | self.end_kitchen_visit(); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 135 | if self.uli_taught { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 136 | return Ok(Outcome::json(StatusCode::OK, forum_thread())); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 137 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 138 | if self.here.thread_rolls >= ULI_READS { |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 139 | let age = httpdate::parse_http_date(ELDER_LAST_MODIFIED) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 140 | .ok() |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 141 | .and_then(|posted| SystemTime::now().duration_since(posted).ok()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 142 | .map_or(0, |age| age.as_secs()); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 143 | return Ok(Outcome::json(StatusCode::OK, forum_thread()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 144 | .header(header::AGE, age.to_string()) |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 145 | .header(header::WARNING, r#"112 - "Disconnected operation""#)); |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 146 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 147 | self.here.thread_rolls += 1; |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 148 | self.touch(); |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 149 | if self.chance( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 150 | self.decision( |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 151 | "teach-uli", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 152 | "Does this reread finally surface the 2009 reply that teaches uli?", |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 153 | ), |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 154 | ULI_ODDS, |
3f9091557ec3 | atagen | 2026-10-11 11:43 UTC | 155 | ) { |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 156 | self.uli_taught = true; |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 157 | return Ok(Outcome::json( |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 158 | StatusCode::OK, |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 159 | 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 | 160 | ) |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 161 | .header(header::LOCATION, self.path("/techniques"))); |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 162 | } |
a6caa2f99786 | atagen | 2026-10-12 10:38 UTC | 163 | Ok(nothing_new()) |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 164 | } |
b85a0d4536c3 | atagen | 2026-10-11 08:50 UTC | 165 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 166 | fn elder_strike(&mut self, problem: Problem) -> Problem { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 167 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 168 | let Elder::Unverified { strikes } = &mut self.elder else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 169 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 170 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 171 | *strikes += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 172 | if *strikes < PATIENCE { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 173 | return problem; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 174 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 175 | self.end(Cause::Banned) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 176 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 177 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 178 | /// 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 | 179 | fn verify_member(&mut self, proxy_authorization: Option<&str>) -> Result<(), Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 180 | if !matches!(self.elder, Elder::Unverified { .. }) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 181 | return Ok(()); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 182 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 183 | let Some(credentials) = proxy_authorization else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 184 | return Err(verification("The forum requires verification.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 185 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 186 | let Some(claimed) = |
782069860236 | atagen | 2026-10-10 12:44 UTC | 187 | parse_credentials(credentials, "ruler").and_then(|v| v.parse::<f64>().ok()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 188 | else { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 189 | return Err(verification("The forum requires verification, in inches.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 190 | }; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 191 | let actual = self.current_length(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 192 | if claimed >= actual + EXAGGERATION { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 193 | self.shame += 2; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 194 | return Err(self.elder_strike(exaggeration())); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 195 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 196 | if !honest(claimed, actual) { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 197 | self.shame += 1; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 198 | return Err(self.elder_strike(verification("Verification failed. The forum can tell."))); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 199 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 200 | self.elder = Elder::Verified; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 201 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 202 | Ok(()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 203 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 204 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 205 | pub fn elder( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 206 | &mut self, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 207 | proxy_authorization: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 208 | if_modified_since: Option<&str>, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 209 | ) -> Result<Outcome, Problem> { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 210 | if self.floor != Floor::Forum { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 211 | return Err(Problem::new( |
782069860236 | atagen | 2026-10-10 12:44 UTC | 212 | StatusCode::NOT_FOUND, |
782069860236 | atagen | 2026-10-10 12:44 UTC | 213 | "elder-absent", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 214 | "The Elder only posts on the forum.", |
782069860236 | atagen | 2026-10-10 12:44 UTC | 215 | )); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 216 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 217 | self.verify_member(proxy_authorization)?; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 218 | |
782069860236 | atagen | 2026-10-10 12:44 UTC | 219 | let last_modified = |
782069860236 | atagen | 2026-10-10 12:44 UTC | 220 | httpdate::parse_http_date(ELDER_LAST_MODIFIED).expect("valid constant date"); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 221 | let current = if_modified_since |
782069860236 | atagen | 2026-10-10 12:44 UTC | 222 | .and_then(|d| httpdate::parse_http_date(d).ok()) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 223 | .is_some_and(|since| since >= last_modified); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 224 | if current { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 225 | if self.elder != Elder::Beaten { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 226 | self.elder = Elder::Beaten; |
782069860236 | atagen | 2026-10-10 12:44 UTC | 227 | self.touch(); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 228 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 229 | return Ok(Outcome::empty(StatusCode::NOT_MODIFIED) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 230 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED)); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 231 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 232 | let spreadsheet = Outcome::raw(StatusCode::OK, "text/csv; header=present", SPREADSHEET) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 233 | .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 234 | if self.filmed_at.is_some() { |
782069860236 | atagen | 2026-10-10 12:44 UTC | 235 | return Ok(spreadsheet.header(X_FORUM_NOTE, "We have seen the footage.")); |
782069860236 | atagen | 2026-10-10 12:44 UTC | 236 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 237 | Ok(spreadsheet) |
782069860236 | atagen | 2026-10-10 12:44 UTC | 238 | } |
782069860236 | atagen | 2026-10-10 12:44 UTC | 239 | } |