atagen

jelq

public

an http based roguelike rpg about jelqing

Star0
Watch0
a11497af08aaaa6aaa48616cc29eec2b48d31d45
1
ssh://brewery@pls.lobotomise.me:33/atagen/jelq.git

Blame: src/game/forum.rs

8b8e83329a1datagen2026-10-12 12:01 UTC1
use std::{sync::LazyLock, time::SystemTime};
a6caa2f99786atagen2026-10-12 10:38 UTC2
782069860236atagen2026-10-10 12:44 UTC3
use axum::http::{StatusCode, header};
782069860236atagen2026-10-10 12:44 UTC4
use serde_json::{Value, json};
782069860236atagen2026-10-10 12:44 UTC5
782069860236atagen2026-10-10 12:44 UTC6
use super::{
8b8e83329a1datagen2026-10-12 12:01 UTC7
    Cause, Floor, Outcome, Run,
880b29a0c11eatagen2026-10-13 09:27 UTC8
    balance::{EXAGGERATION, MEDITATION_ODDS, PATIENCE, THREAD_READS, ULI_ODDS},
8b8e83329a1datagen2026-10-12 12:01 UTC9
    credentials::{Scheme, parse_credentials},
8b8e83329a1datagen2026-10-12 12:01 UTC10
    measure::{exaggeration, honest},
782069860236atagen2026-10-10 12:44 UTC11
};
782069860236atagen2026-10-10 12:44 UTC12
use crate::{headers::X_FORUM_NOTE, problem::Problem};
782069860236atagen2026-10-10 12:44 UTC13
782069860236atagen2026-10-10 12:44 UTC14
pub const FORUM_THREAD: &str = "/forum/threads/2009";
782069860236atagen2026-10-10 12:44 UTC15
pub const ELDER_LAST_MODIFIED: &str = "Sun, 14 Jun 2009 03:12:00 GMT";
8b8e83329a1datagen2026-10-12 12:01 UTC16
static ELDER_POSTED: LazyLock<SystemTime> = LazyLock::new(|| {
8b8e83329a1datagen2026-10-12 12:01 UTC17
    httpdate::parse_http_date(ELDER_LAST_MODIFIED).expect("the Elder's date is a valid HTTP-date")
8b8e83329a1datagen2026-10-12 12:01 UTC18
});
782069860236atagen2026-10-10 12:44 UTC19
782069860236atagen2026-10-10 12:44 UTC20
const SPREADSHEET: &str = "\
782069860236atagen2026-10-10 12:44 UTC21
date,length,girth,technique,notes,honest?
782069860236atagen2026-10-10 12:44 UTC22
2007-01-03,7.50,5.50,wet,baseline,no
782069860236atagen2026-10-10 12:44 UTC23
2007-06-11,7.50,5.50,wet,feeling fuller,no
782069860236atagen2026-10-10 12:44 UTC24
2008-01-02,7.50,5.50,dry,new routine,no
782069860236atagen2026-10-10 12:44 UTC25
2008-09-19,7.50,5.50,uli,PUT is idempotent. do not use PUT.,no
782069860236atagen2026-10-10 12:44 UTC26
2009-06-14,7.50,5.50,wet,progress is slow but real,no
782069860236atagen2026-10-10 12:44 UTC27
";
782069860236atagen2026-10-10 12:44 UTC28
a11497af08aaatagen2026-10-13 12:04 UTC29
fn thread(detail: Option<&str>) -> Outcome {
a11497af08aaatagen2026-10-13 12:04 UTC30
    let mut body = forum_thread();
a11497af08aaatagen2026-10-13 12:04 UTC31
    if let Some(detail) = detail {
a11497af08aaatagen2026-10-13 12:04 UTC32
        body["detail"] = json!(detail);
a11497af08aaatagen2026-10-13 12:04 UTC33
    }
a11497af08aaatagen2026-10-13 12:04 UTC34
    Outcome::json(StatusCode::OK, body).header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED)
a11497af08aaatagen2026-10-13 12:04 UTC35
}
a11497af08aaatagen2026-10-13 12:04 UTC36
a6caa2f99786atagen2026-10-12 10:38 UTC37
fn nothing_new() -> Outcome {
a11497af08aaatagen2026-10-13 12:04 UTC38
    thread(None).header(
a6caa2f99786atagen2026-10-12 10:38 UTC39
        header::WARNING,
a6caa2f99786atagen2026-10-12 10:38 UTC40
        r#"199 - "Nothing new has been posted since 2009.""#,
a6caa2f99786atagen2026-10-12 10:38 UTC41
    )
a6caa2f99786atagen2026-10-12 10:38 UTC42
}
a6caa2f99786atagen2026-10-12 10:38 UTC43
782069860236atagen2026-10-10 12:44 UTC44
pub fn forum_thread() -> Value {
782069860236atagen2026-10-10 12:44 UTC45
    json!({
782069860236atagen2026-10-10 12:44 UTC46
        "title": "The definitive jelqing FAQ (updated 2009)",
782069860236atagen2026-10-10 12:44 UTC47
        "posts": [
782069860236atagen2026-10-10 12:44 UTC48
            { "author": "TheElder", "body": "Warm up. Always warm up. A cold jelq is a 412 waiting to happen." },
782069860236atagen2026-10-10 12:44 UTC49
            { "author": "TheElder", "body": "Keep EQ between 50 and 70. Above 70 you are gambling. Above 90 you are a cautionary tale." },
0fdc47364c8catagen2026-10-11 04:45 UTC50
            { "author": "newbie_2009", "body": "everyone keeps saying uli. who is uli" },
0fdc47364c8catagen2026-10-11 04:45 UTC51
            { "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." },
0fdc47364c8catagen2026-10-11 04:45 UTC52
            { "author": "TheElder", "body": "We do not say his name in vain. We say it in girth." },
782069860236atagen2026-10-10 12:44 UTC53
            { "author": "newbie_2009", "body": "I have been sending PUT for three weeks and nothing has changed." },
782069860236atagen2026-10-10 12:44 UTC54
            { "author": "TheElder", "body": "PUT is idempotent. Read the spec." },
782069860236atagen2026-10-10 12:44 UTC55
            { "author": "TheElder", "body": "Members verify with a Ruler. Proxy-Authorization, inches, no rounding up. We can tell." },
782069860236atagen2026-10-10 12:44 UTC56
            { "author": "throwaway_77", "body": "my doctor said i was normal. i didnt believe him. i still dont know what he meant by bearer" },
782069860236atagen2026-10-10 12:44 UTC57
            { "author": "TheElder", "body": "My numbers are in my spreadsheet. They have not changed since 2009. Nothing about me has changed since 2009." },
782069860236atagen2026-10-10 12:44 UTC58
        ],
782069860236atagen2026-10-10 12:44 UTC59
    })
782069860236atagen2026-10-10 12:44 UTC60
}
782069860236atagen2026-10-10 12:44 UTC61
782069860236atagen2026-10-10 12:44 UTC62
fn verification(detail: &str) -> Problem {
782069860236atagen2026-10-10 12:44 UTC63
    Problem::new(
782069860236atagen2026-10-10 12:44 UTC64
        StatusCode::PROXY_AUTHENTICATION_REQUIRED,
782069860236atagen2026-10-10 12:44 UTC65
        "verification-required",
782069860236atagen2026-10-10 12:44 UTC66
        detail,
782069860236atagen2026-10-10 12:44 UTC67
    )
782069860236atagen2026-10-10 12:44 UTC68
    .header(header::PROXY_AUTHENTICATE, "Ruler realm=\"forum\"")
782069860236atagen2026-10-10 12:44 UTC69
}
782069860236atagen2026-10-10 12:44 UTC70
8b8e83329a1datagen2026-10-12 12:01 UTC71
/// The browser tab that opens on turn 10.
8b8e83329a1datagen2026-10-12 12:01 UTC72
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
8b8e83329a1datagen2026-10-12 12:01 UTC73
pub enum Story {
8b8e83329a1datagen2026-10-12 12:01 UTC74
    Unopened,
8b8e83329a1datagen2026-10-12 12:01 UTC75
    Pending,
8b8e83329a1datagen2026-10-12 12:01 UTC76
    ReadForum,
8b8e83329a1datagen2026-10-12 12:01 UTC77
    ClosedTab,
8b8e83329a1datagen2026-10-12 12:01 UTC78
}
8b8e83329a1datagen2026-10-12 12:01 UTC79
8b8e83329a1datagen2026-10-12 12:01 UTC80
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
8b8e83329a1datagen2026-10-12 12:01 UTC81
pub enum Branch {
8b8e83329a1datagen2026-10-12 12:01 UTC82
    Forum,
8b8e83329a1datagen2026-10-12 12:01 UTC83
    CloseTab,
8b8e83329a1datagen2026-10-12 12:01 UTC84
}
8b8e83329a1datagen2026-10-12 12:01 UTC85
8b8e83329a1datagen2026-10-12 12:01 UTC86
impl Branch {
8b8e83329a1datagen2026-10-12 12:01 UTC87
    pub fn slug(self) -> &'static str {
8b8e83329a1datagen2026-10-12 12:01 UTC88
        match self {
8b8e83329a1datagen2026-10-12 12:01 UTC89
            Self::Forum => "forum",
8b8e83329a1datagen2026-10-12 12:01 UTC90
            Self::CloseTab => "close-tab",
8b8e83329a1datagen2026-10-12 12:01 UTC91
        }
8b8e83329a1datagen2026-10-12 12:01 UTC92
    }
8b8e83329a1datagen2026-10-12 12:01 UTC93
}
8b8e83329a1datagen2026-10-12 12:01 UTC94
8b8e83329a1datagen2026-10-12 12:01 UTC95
impl std::str::FromStr for Branch {
8b8e83329a1datagen2026-10-12 12:01 UTC96
    type Err = ();
8b8e83329a1datagen2026-10-12 12:01 UTC97
8b8e83329a1datagen2026-10-12 12:01 UTC98
    fn from_str(slug: &str) -> Result<Self, ()> {
8b8e83329a1datagen2026-10-12 12:01 UTC99
        [Self::Forum, Self::CloseTab]
8b8e83329a1datagen2026-10-12 12:01 UTC100
            .into_iter()
8b8e83329a1datagen2026-10-12 12:01 UTC101
            .find(|branch| branch.slug() == slug)
8b8e83329a1datagen2026-10-12 12:01 UTC102
            .ok_or(())
8b8e83329a1datagen2026-10-12 12:01 UTC103
    }
8b8e83329a1datagen2026-10-12 12:01 UTC104
}
8b8e83329a1datagen2026-10-12 12:01 UTC105
8b8e83329a1datagen2026-10-12 12:01 UTC106
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
8b8e83329a1datagen2026-10-12 12:01 UTC107
pub enum Elder {
8b8e83329a1datagen2026-10-12 12:01 UTC108
    Unverified { strikes: u8 },
8b8e83329a1datagen2026-10-12 12:01 UTC109
    Verified,
8b8e83329a1datagen2026-10-12 12:01 UTC110
    Beaten,
8b8e83329a1datagen2026-10-12 12:01 UTC111
}
8b8e83329a1datagen2026-10-12 12:01 UTC112
8b8e83329a1datagen2026-10-12 12:01 UTC113
/// The run's life online, from the tab on turn 10 to the footage the neighbour took.
8b8e83329a1datagen2026-10-12 12:01 UTC114
pub struct Online {
8b8e83329a1datagen2026-10-12 12:01 UTC115
    pub(crate) story: Story,
880b29a0c11eatagen2026-10-13 09:27 UTC116
    pub(crate) meditation_taught: bool,
8b8e83329a1datagen2026-10-12 12:01 UTC117
    pub(crate) uli_taught: bool,
8b8e83329a1datagen2026-10-12 12:01 UTC118
    pub(crate) elder: Elder,
8b8e83329a1datagen2026-10-12 12:01 UTC119
    pub(crate) filmed_at: Option<SystemTime>,
8b8e83329a1datagen2026-10-12 12:01 UTC120
}
8b8e83329a1datagen2026-10-12 12:01 UTC121
8b8e83329a1datagen2026-10-12 12:01 UTC122
impl Default for Online {
8b8e83329a1datagen2026-10-12 12:01 UTC123
    fn default() -> Self {
8b8e83329a1datagen2026-10-12 12:01 UTC124
        Self {
8b8e83329a1datagen2026-10-12 12:01 UTC125
            story: Story::Unopened,
880b29a0c11eatagen2026-10-13 09:27 UTC126
            meditation_taught: false,
8b8e83329a1datagen2026-10-12 12:01 UTC127
            uli_taught: false,
8b8e83329a1datagen2026-10-12 12:01 UTC128
            elder: Elder::Unverified { strikes: 0 },
8b8e83329a1datagen2026-10-12 12:01 UTC129
            filmed_at: None,
8b8e83329a1datagen2026-10-12 12:01 UTC130
        }
8b8e83329a1datagen2026-10-12 12:01 UTC131
    }
8b8e83329a1datagen2026-10-12 12:01 UTC132
}
8b8e83329a1datagen2026-10-12 12:01 UTC133
782069860236atagen2026-10-10 12:44 UTC134
impl Run {
782069860236atagen2026-10-10 12:44 UTC135
    pub(super) fn branch_offer(&self) -> Outcome {
8b8e83329a1datagen2026-10-12 12:01 UTC136
        let forum = self.path(&format!("/branches/{}", Branch::Forum.slug()));
8b8e83329a1datagen2026-10-12 12:01 UTC137
        let close = self.path(&format!("/branches/{}", Branch::CloseTab.slug()));
782069860236atagen2026-10-10 12:44 UTC138
        Outcome::json(
782069860236atagen2026-10-10 12:44 UTC139
            StatusCode::MULTIPLE_CHOICES,
782069860236atagen2026-10-10 12:44 UTC140
            json!({
782069860236atagen2026-10-10 12:44 UTC141
                "detail": "A browser tab is open. It has been open for some time.",
782069860236atagen2026-10-10 12:44 UTC142
                "choices": [
782069860236atagen2026-10-10 12:44 UTC143
                    { "href": forum, "method": "POST", "title": "Read the forum" },
782069860236atagen2026-10-10 12:44 UTC144
                    { "href": close, "method": "POST", "title": "Close the tab" },
782069860236atagen2026-10-10 12:44 UTC145
                ],
782069860236atagen2026-10-10 12:44 UTC146
            }),
782069860236atagen2026-10-10 12:44 UTC147
        )
782069860236atagen2026-10-10 12:44 UTC148
        .header(
782069860236atagen2026-10-10 12:44 UTC149
            header::LINK,
782069860236atagen2026-10-10 12:44 UTC150
            format!(
d46f9d0b953aatagen2026-10-10 14:41 UTC151
                "<{forum}>; rel=\"alternate\"; title=\"Read the forum\"; allow=\"POST\", <{close}>; rel=\"alternate\"; title=\"Close the tab\"; allow=\"POST\""
782069860236atagen2026-10-10 12:44 UTC152
            ),
782069860236atagen2026-10-10 12:44 UTC153
        )
782069860236atagen2026-10-10 12:44 UTC154
    }
782069860236atagen2026-10-10 12:44 UTC155
8b8e83329a1datagen2026-10-12 12:01 UTC156
    pub fn choose(&mut self, choice: Branch) -> Result<Outcome, Problem> {
8b8e83329a1datagen2026-10-12 12:01 UTC157
        if self.online.story != Story::Pending {
782069860236atagen2026-10-10 12:44 UTC158
            return Err(Problem::new(
782069860236atagen2026-10-10 12:44 UTC159
                StatusCode::CONFLICT,
782069860236atagen2026-10-10 12:44 UTC160
                "no-decision-pending",
782069860236atagen2026-10-10 12:44 UTC161
                "There is no decision pending.",
782069860236atagen2026-10-10 12:44 UTC162
            ));
782069860236atagen2026-10-10 12:44 UTC163
        }
782069860236atagen2026-10-10 12:44 UTC164
        let (story, location, detail) = match choice {
8b8e83329a1datagen2026-10-12 12:01 UTC165
            Branch::Forum => {
8b8e83329a1datagen2026-10-12 12:01 UTC166
                self.standing.shame += 3;
880b29a0c11eatagen2026-10-13 09:27 UTC167
                let detail = if self.learn_meditation() {
880b29a0c11eatagen2026-10-13 09:27 UTC168
                    "The thread is from 2009. A technique called uli is discussed at length. Further down, someone explains how to breathe, and you write it down."
880b29a0c11eatagen2026-10-13 09:27 UTC169
                } else {
880b29a0c11eatagen2026-10-13 09:27 UTC170
                    "The thread is from 2009. A technique called uli is discussed at length."
880b29a0c11eatagen2026-10-13 09:27 UTC171
                };
0fdc47364c8catagen2026-10-11 04:45 UTC172
                (Story::ReadForum, self.path("/techniques"), detail)
782069860236atagen2026-10-10 12:44 UTC173
            }
8b8e83329a1datagen2026-10-12 12:01 UTC174
            Branch::CloseTab => {
8b8e83329a1datagen2026-10-12 12:01 UTC175
                self.standing.suspicion = 0;
782069860236atagen2026-10-10 12:44 UTC176
                (
782069860236atagen2026-10-10 12:44 UTC177
                    Story::ClosedTab,
782069860236atagen2026-10-10 12:44 UTC178
                    self.path(""),
782069860236atagen2026-10-10 12:44 UTC179
                    "The tab is closed. Nobody saw it.",
782069860236atagen2026-10-10 12:44 UTC180
                )
782069860236atagen2026-10-10 12:44 UTC181
            }
782069860236atagen2026-10-10 12:44 UTC182
        };
8b8e83329a1datagen2026-10-12 12:01 UTC183
        self.online.story = story;
782069860236atagen2026-10-10 12:44 UTC184
        self.touch();
782069860236atagen2026-10-10 12:44 UTC185
        Ok(
782069860236atagen2026-10-10 12:44 UTC186
            Outcome::json(StatusCode::SEE_OTHER, json!({ "detail": detail }))
782069860236atagen2026-10-10 12:44 UTC187
                .header(header::LOCATION, location),
782069860236atagen2026-10-10 12:44 UTC188
        )
782069860236atagen2026-10-10 12:44 UTC189
    }
782069860236atagen2026-10-10 12:44 UTC190
a6caa2f99786atagen2026-10-12 10:38 UTC191
    /// Re-reading is free. Each floor gets a couple of live reads that may surface the reply,
a6caa2f99786atagen2026-10-12 10:38 UTC192
    /// after which the forum is down and the browser serves what it kept.
b85a0d4536c3atagen2026-10-11 08:50 UTC193
    pub fn read_thread(&mut self) -> Result<Outcome, Problem> {
8b8e83329a1datagen2026-10-12 12:01 UTC194
        if self.online.story == Story::Pending {
b85a0d4536c3atagen2026-10-11 08:50 UTC195
            return Ok(self.branch_offer());
b85a0d4536c3atagen2026-10-11 08:50 UTC196
        }
e807266c323batagen2026-10-12 09:46 UTC197
        if !self.thread_reachable() {
e807266c323batagen2026-10-12 09:46 UTC198
            return Err(Problem::new(
e807266c323batagen2026-10-12 09:46 UTC199
                StatusCode::NOT_FOUND,
e807266c323batagen2026-10-12 09:46 UTC200
                "no-thread",
a11497af08aaatagen2026-10-13 12:04 UTC201
                "There is no thread. Nobody has mentioned a forum yet.",
e807266c323batagen2026-10-12 09:46 UTC202
            ));
e807266c323batagen2026-10-12 09:46 UTC203
        }
5cc6ab966f30atagen2026-10-11 11:23 UTC204
        self.end_kitchen_visit();
8b8e83329a1datagen2026-10-12 12:01 UTC205
        if self.online.uli_taught {
a11497af08aaatagen2026-10-13 12:04 UTC206
            return Ok(thread(None));
b85a0d4536c3atagen2026-10-11 08:50 UTC207
        }
880b29a0c11eatagen2026-10-13 09:27 UTC208
        if self.here.thread_rolls >= THREAD_READS {
8b8e83329a1datagen2026-10-12 12:01 UTC209
            let age = SystemTime::now()
8b8e83329a1datagen2026-10-12 12:01 UTC210
                .duration_since(*ELDER_POSTED)
a6caa2f99786atagen2026-10-12 10:38 UTC211
                .map_or(0, |age| age.as_secs());
a11497af08aaatagen2026-10-13 12:04 UTC212
            return Ok(thread(None)
a6caa2f99786atagen2026-10-12 10:38 UTC213
                .header(header::AGE, age.to_string())
a6caa2f99786atagen2026-10-12 10:38 UTC214
                .header(header::WARNING, r#"112 - "Disconnected operation""#));
a6caa2f99786atagen2026-10-12 10:38 UTC215
        }
a6caa2f99786atagen2026-10-12 10:38 UTC216
        self.here.thread_rolls += 1;
a6caa2f99786atagen2026-10-12 10:38 UTC217
        self.touch();
880b29a0c11eatagen2026-10-13 09:27 UTC218
        let detail = if !self.online.meditation_taught {
880b29a0c11eatagen2026-10-13 09:27 UTC219
            if !self.learn_meditation() {
880b29a0c11eatagen2026-10-13 09:27 UTC220
                return Ok(nothing_new());
880b29a0c11eatagen2026-10-13 09:27 UTC221
            }
880b29a0c11eatagen2026-10-13 09:27 UTC222
            "Between two arguments about pumps, a reply explains how to breathe. In through the nose, out through the mouth. You write it down."
880b29a0c11eatagen2026-10-13 09:27 UTC223
        } else {
880b29a0c11eatagen2026-10-13 09:27 UTC224
            if !self.chance(
880b29a0c11eatagen2026-10-13 09:27 UTC225
                self.decision(
880b29a0c11eatagen2026-10-13 09:27 UTC226
                    "teach-uli",
a11497af08aaatagen2026-10-13 12:04 UTC227
                    "Does this read finally surface the 2009 reply that teaches uli?",
880b29a0c11eatagen2026-10-13 09:27 UTC228
                ),
880b29a0c11eatagen2026-10-13 09:27 UTC229
                ULI_ODDS,
880b29a0c11eatagen2026-10-13 09:27 UTC230
            ) {
880b29a0c11eatagen2026-10-13 09:27 UTC231
                return Ok(nothing_new());
880b29a0c11eatagen2026-10-13 09:27 UTC232
            }
880b29a0c11eatagen2026-10-13 09:27 UTC233
            self.online.uli_taught = true;
880b29a0c11eatagen2026-10-13 09:27 UTC234
            "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."
880b29a0c11eatagen2026-10-13 09:27 UTC235
        };
a11497af08aaatagen2026-10-13 12:04 UTC236
        Ok(thread(Some(detail)))
880b29a0c11eatagen2026-10-13 09:27 UTC237
    }
880b29a0c11eatagen2026-10-13 09:27 UTC238
880b29a0c11eatagen2026-10-13 09:27 UTC239
    fn learn_meditation(&mut self) -> bool {
880b29a0c11eatagen2026-10-13 09:27 UTC240
        let taught = self.chance(
3f9091557ec3atagen2026-10-11 11:43 UTC241
            self.decision(
880b29a0c11eatagen2026-10-13 09:27 UTC242
                "teach-meditation",
880b29a0c11eatagen2026-10-13 09:27 UTC243
                "Does the thread surface the reply that teaches the breathing technique?",
3f9091557ec3atagen2026-10-11 11:43 UTC244
            ),
880b29a0c11eatagen2026-10-13 09:27 UTC245
            MEDITATION_ODDS,
880b29a0c11eatagen2026-10-13 09:27 UTC246
        );
880b29a0c11eatagen2026-10-13 09:27 UTC247
        self.online.meditation_taught |= taught;
880b29a0c11eatagen2026-10-13 09:27 UTC248
        taught
b85a0d4536c3atagen2026-10-11 08:50 UTC249
    }
b85a0d4536c3atagen2026-10-11 08:50 UTC250
782069860236atagen2026-10-10 12:44 UTC251
    fn elder_strike(&mut self, problem: Problem) -> Problem {
782069860236atagen2026-10-10 12:44 UTC252
        self.touch();
8b8e83329a1datagen2026-10-12 12:01 UTC253
        let Elder::Unverified { strikes } = &mut self.online.elder else {
782069860236atagen2026-10-10 12:44 UTC254
            return problem;
782069860236atagen2026-10-10 12:44 UTC255
        };
782069860236atagen2026-10-10 12:44 UTC256
        *strikes += 1;
782069860236atagen2026-10-10 12:44 UTC257
        if *strikes < PATIENCE {
782069860236atagen2026-10-10 12:44 UTC258
            return problem;
782069860236atagen2026-10-10 12:44 UTC259
        }
782069860236atagen2026-10-10 12:44 UTC260
        self.end(Cause::Banned)
782069860236atagen2026-10-10 12:44 UTC261
    }
782069860236atagen2026-10-10 12:44 UTC262
782069860236atagen2026-10-10 12:44 UTC263
    /// Failed verification counts toward a ban even on GET, the way repeated bad credentials lock an account.
782069860236atagen2026-10-10 12:44 UTC264
    fn verify_member(&mut self, proxy_authorization: Option<&str>) -> Result<(), Problem> {
8b8e83329a1datagen2026-10-12 12:01 UTC265
        if !matches!(self.online.elder, Elder::Unverified { .. }) {
782069860236atagen2026-10-10 12:44 UTC266
            return Ok(());
782069860236atagen2026-10-10 12:44 UTC267
        }
782069860236atagen2026-10-10 12:44 UTC268
        let Some(credentials) = proxy_authorization else {
782069860236atagen2026-10-10 12:44 UTC269
            return Err(verification("The forum requires verification."));
782069860236atagen2026-10-10 12:44 UTC270
        };
782069860236atagen2026-10-10 12:44 UTC271
        let Some(claimed) =
8b8e83329a1datagen2026-10-12 12:01 UTC272
            parse_credentials(credentials, Scheme::Ruler).and_then(|v| v.parse::<f64>().ok())
782069860236atagen2026-10-10 12:44 UTC273
        else {
782069860236atagen2026-10-10 12:44 UTC274
            return Err(verification("The forum requires verification, in inches."));
782069860236atagen2026-10-10 12:44 UTC275
        };
782069860236atagen2026-10-10 12:44 UTC276
        let actual = self.current_length();
782069860236atagen2026-10-10 12:44 UTC277
        if claimed >= actual + EXAGGERATION {
8b8e83329a1datagen2026-10-12 12:01 UTC278
            self.standing.shame += 2;
782069860236atagen2026-10-10 12:44 UTC279
            return Err(self.elder_strike(exaggeration()));
782069860236atagen2026-10-10 12:44 UTC280
        }
782069860236atagen2026-10-10 12:44 UTC281
        if !honest(claimed, actual) {
8b8e83329a1datagen2026-10-12 12:01 UTC282
            self.standing.shame += 1;
058650ec79d6atagen2026-10-12 10:49 UTC283
            let failed = verification("Verification failed. The forum can tell.");
058650ec79d6atagen2026-10-12 10:49 UTC284
            if self.girth_respected() {
058650ec79d6atagen2026-10-12 10:49 UTC285
                return Err(failed.header(
058650ec79d6atagen2026-10-12 10:49 UTC286
                    X_FORUM_NOTE,
058650ec79d6atagen2026-10-12 10:49 UTC287
                    "The mods have let this one go. Girth is also a dimension.",
058650ec79d6atagen2026-10-12 10:49 UTC288
                ));
058650ec79d6atagen2026-10-12 10:49 UTC289
            }
058650ec79d6atagen2026-10-12 10:49 UTC290
            return Err(self.elder_strike(failed));
782069860236atagen2026-10-10 12:44 UTC291
        }
8b8e83329a1datagen2026-10-12 12:01 UTC292
        self.online.elder = Elder::Verified;
782069860236atagen2026-10-10 12:44 UTC293
        self.touch();
782069860236atagen2026-10-10 12:44 UTC294
        Ok(())
782069860236atagen2026-10-10 12:44 UTC295
    }
782069860236atagen2026-10-10 12:44 UTC296
782069860236atagen2026-10-10 12:44 UTC297
    pub fn elder(
782069860236atagen2026-10-10 12:44 UTC298
        &mut self,
782069860236atagen2026-10-10 12:44 UTC299
        proxy_authorization: Option<&str>,
782069860236atagen2026-10-10 12:44 UTC300
        if_modified_since: Option<&str>,
782069860236atagen2026-10-10 12:44 UTC301
    ) -> Result<Outcome, Problem> {
782069860236atagen2026-10-10 12:44 UTC302
        if self.floor != Floor::Forum {
782069860236atagen2026-10-10 12:44 UTC303
            return Err(Problem::new(
782069860236atagen2026-10-10 12:44 UTC304
                StatusCode::NOT_FOUND,
782069860236atagen2026-10-10 12:44 UTC305
                "elder-absent",
782069860236atagen2026-10-10 12:44 UTC306
                "The Elder only posts on the forum.",
782069860236atagen2026-10-10 12:44 UTC307
            ));
782069860236atagen2026-10-10 12:44 UTC308
        }
782069860236atagen2026-10-10 12:44 UTC309
        self.verify_member(proxy_authorization)?;
782069860236atagen2026-10-10 12:44 UTC310
782069860236atagen2026-10-10 12:44 UTC311
        let current = if_modified_since
782069860236atagen2026-10-10 12:44 UTC312
            .and_then(|d| httpdate::parse_http_date(d).ok())
8b8e83329a1datagen2026-10-12 12:01 UTC313
            .is_some_and(|since| since >= *ELDER_POSTED);
782069860236atagen2026-10-10 12:44 UTC314
        if current {
8b8e83329a1datagen2026-10-12 12:01 UTC315
            if self.online.elder != Elder::Beaten {
8b8e83329a1datagen2026-10-12 12:01 UTC316
                self.online.elder = Elder::Beaten;
782069860236atagen2026-10-10 12:44 UTC317
                self.touch();
782069860236atagen2026-10-10 12:44 UTC318
            }
782069860236atagen2026-10-10 12:44 UTC319
            return Ok(Outcome::empty(StatusCode::NOT_MODIFIED)
782069860236atagen2026-10-10 12:44 UTC320
                .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED));
782069860236atagen2026-10-10 12:44 UTC321
        }
782069860236atagen2026-10-10 12:44 UTC322
        let spreadsheet = Outcome::raw(StatusCode::OK, "text/csv; header=present", SPREADSHEET)
782069860236atagen2026-10-10 12:44 UTC323
            .header(header::LAST_MODIFIED, ELDER_LAST_MODIFIED);
8b8e83329a1datagen2026-10-12 12:01 UTC324
        if self.online.filmed_at.is_some() {
782069860236atagen2026-10-10 12:44 UTC325
            return Ok(spreadsheet.header(X_FORUM_NOTE, "We have seen the footage."));
782069860236atagen2026-10-10 12:44 UTC326
        }
782069860236atagen2026-10-10 12:44 UTC327
        Ok(spreadsheet)
782069860236atagen2026-10-10 12:44 UTC328
    }
782069860236atagen2026-10-10 12:44 UTC329
}