MT: add session read warnings, partial index on removed_at - Log tracing::warn on session read errors in MaybeUser extractor instead of silently swallowing with .ok() - Add partial index idx_posts_not_removed for soft-delete filtering
- Co-Authored-By
Author: Max J. <87768334+MaxJMath@users.noreply.github.com> - 2026-04-22 23:23 UTC
Commit:
0e8f693568675106b96a542d756a550d8c9554c8Parent:
2 files changed,
+17 insertions,
-2 deletions
OldNewLine
@@ -53,8 +53,20 @@
53
53
54
54
impl SessionUser {55
55
async fn from_session(session: &Session) -> Option<Self> {56
let user_id: uuid::Uuid = session.get(SESSION_USER_ID).await.ok()??;57
let username: String = session.get(SESSION_USERNAME).await.ok()??;56
let user_id: uuid::Uuid = match session.get(SESSION_USER_ID).await {57
Ok(v) => v?,58
Err(e) => {59
tracing::warn!(error = %e, "failed to read user_id from session");60
return None;61
}62
};63
let username: String = match session.get(SESSION_USERNAME).await {64
Ok(v) => v?,65
Err(e) => {66
tracing::warn!(error = %e, "failed to read username from session");67
return None;68
}69
};58
70
let display_name: Option<String> = session.get(SESSION_DISPLAY_NAME).await.ok().flatten();59
71
Some(Self {60
72
user_id,OldNewLine
@@ -1,0 +1,3 @@
1
-- Partial index for soft-deleted post filtering (WHERE removed_at IS NULL).2
CREATE INDEX IF NOT EXISTS idx_posts_not_removed3
ON posts(thread_id, created_at) WHERE removed_at IS NULL;