atagen

jelq

public

an http based roguelike rpg about jelqing

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