Browse Source

Review fixes

pull/7346/head
Timshel 4 weeks ago
parent
commit
5261bd7b0d
  1. 14
      src/api/core/sends.rs
  2. 20
      src/auth/send.rs

14
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
}

20
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<Self, Self::Error> {
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(),
})
}

Loading…
Cancel
Save