From 20862a8081bbd3c5fb727f130d33cd47306c5b0f Mon Sep 17 00:00:00 2001 From: Butter Cat Date: Thu, 25 Jun 2026 20:21:45 -0400 Subject: [PATCH 1/2] feat: support share links for posts on a user's profile --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index 399c0c9c..c3c81e1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -384,6 +384,22 @@ async fn main() { } }) }); + app.at("/u/:name/s/:id").get(|req: Request| { + Box::pin(async move { + let name = req.param("name").unwrap_or_default(); + match req.param("id").as_deref() { + // User post share link + Some(id) if (8..12).contains(&id.len()) => match canonical_path(format!("/u/{name}/s/{id}"), 3).await { + Ok(Some(path)) => Ok(redirect(&path)), + Ok(None) => error(req, "Post ID is invalid. It may point to a post on a user that has been banned.").await, + Err(e) => error(req, &e).await, + }, + + // Error message for unknown pages + _ => error(req, "Nothing here").await, + } + }) + }); app.at("/:id").get(|req: Request| { Box::pin(async move { From 7a284d301c5fecb657a6330e18bf461d5f679aab Mon Sep 17 00:00:00 2001 From: Butter Cat Date: Thu, 25 Jun 2026 20:22:50 -0400 Subject: [PATCH 2/2] docs: clarify what type of share links the subreddit post share link handler was working with --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c3c81e1d..8e95461d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -372,7 +372,7 @@ async fn main() { Box::pin(async move { let sub = req.param("sub").unwrap_or_default(); match req.param("id").as_deref() { - // Share link + // Subreddit post share link Some(id) if (8..12).contains(&id.len()) => match canonical_path(format!("/r/{sub}/s/{id}"), 3).await { Ok(Some(path)) => Ok(redirect(&path)), Ok(None) => error(req, "Post ID is invalid. It may point to a post on a community that has been banned.").await,