//! `/out?u=<url>&s=<sig>`: the page between a post's off-site link and the
//! site it points to (crate::links). It never redirects by itself. A signed
//! destination gets Continue; an unsigned or altered one is shown as text
//! with a warning, so `/out` can't be used to bounce people anywhere.
use axum::extract::{Query, State};
use axum::http::StatusCode;
use axum::response::Html;
use minijinja::context;
use serde::Deserialize;
use crate::links::{destination, Links};
use crate::middleware::UserContext;
use crate::AppState;
use super::render;
#[derive(Debug, Deserialize)]
pub struct OutQuery {
pub u: Option<String>,
pub s: Option<String>,
}
pub async fn out(
State(state): State<AppState>,
Query(q): Query<OutQuery>,
user: Option<UserContext>,
) -> Result<Html<String>, StatusCode> {
let links = Links::from_config(&state.config);
let raw = q.u.unwrap_or_default();
let dest = destination(&raw);
let signed = dest.is_some() && q.s.as_deref().is_some_and(|s| links.signer().verify(&raw, s));
render(&state, "out.html", context! {
title => "Leaving",
app_name => state.config.app_name,
user => user.map(|u| u.user),
here => links.host(),
raw => raw,
dest => dest,
signed => signed,
})
}
neiam
/recourse
public · Issues · Pulls · Labels · Forks · Compare · Actions running · Badges · Packages
⭐
Log in to mark this repository.
1.3 KiB · text
History
7250478