From 5261bd7b0dffcd344b39074bac6e3e5d9d63710c Mon Sep 17 00:00:00 2001 From: Timshel Date: Sat, 27 Jun 2026 23:16:30 +0200 Subject: [PATCH] Review fixes --- src/api/core/sends.rs | 14 +++++++------- src/auth/send.rs | 20 ++------------------ 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/api/core/sends.rs b/src/api/core/sends.rs index 87401b52..fb3ee48f 100644 --- a/src/api/core/sends.rs +++ b/src/api/core/sends.rs @@ -495,13 +495,6 @@ async fn post_access_legacy( err_code!(SEND_INACCESSIBLE_MSG, 404) } - // Files are incremented during the download - if send.atype == SendType::Text as i32 { - send.access_count += 1; - } - - send.save(&conn).await?; - if send.password_hash.is_some() { match data.into_inner().password { Some(ref p) if send.check_password(p) => { /* Nothing to do here */ } @@ -510,6 +503,13 @@ async fn post_access_legacy( } } + // Files are incremented during the download + if send.atype == SendType::Text as i32 { + send.access_count += 1; + } + + send.save(&conn).await?; + process_access(send, conn, nt).await } diff --git a/src/auth/send.rs b/src/auth/send.rs index f9f34110..84500b6a 100644 --- a/src/auth/send.rs +++ b/src/auth/send.rs @@ -1,14 +1,11 @@ use chrono::{TimeDelta, Utc}; -use rocket::{ - outcome::try_outcome, - request::{FromRequest, Outcome, Request}, -}; +use rocket::request::{FromRequest, Outcome, Request}; use crate::{ api::ApiResult, auth, - auth::{BasicJwtClaims, ClientIp, Host}, + auth::{BasicJwtClaims, ClientIp}, db::{ DbConn, models::{Send, SendId}, @@ -126,12 +123,6 @@ impl SendTokens { } pub struct SendHeaders { - #[expect(dead_code)] - pub host: String, - - #[expect(dead_code)] - pub ip: ClientIp, - pub send_id: SendId, } @@ -142,11 +133,6 @@ impl<'r> FromRequest<'r> for SendHeaders { async fn from_request(request: &'r Request<'_>) -> Outcome { let headers = request.headers(); - let host = try_outcome!(Host::from_request(request).await).host; - let Outcome::Success(ip) = ClientIp::from_request(request).await else { - err_handler!("Error getting Client IP") - }; - // Get access_token let access_token: &str = if let Some(a) = headers.get_one("Authorization") { if let Some(split) = a.rsplit("Bearer ").next() { @@ -164,8 +150,6 @@ impl<'r> FromRequest<'r> for SendHeaders { }; Outcome::Success(SendHeaders { - host, - ip, send_id: claims.sub.into(), }) }