refactor: Upload extractor, 429 refusal test, stricter contract test

This commit is contained in:
2026-10-25 21:59:31 +01:00
parent c8d9138349
commit 2ac1d4e0cf
10 changed files with 139 additions and 52 deletions

View File

@@ -1,4 +1,4 @@
use crate::extractors::{Body, PathId};
use crate::extractors::{Body, PathId, Upload};
use crate::support::str_to_domain_field;
use crate::{errors::ApiError, extractors::AuthenticatedUser, state::AppState};
use api_types::{
@@ -14,10 +14,7 @@ use application::import::{
create_session as create_import_session, execute as execute_import, get_preview_stage,
get_session_state,
};
use axum::{
extract::{Multipart, State},
response::IntoResponse,
};
use axum::{extract::State, response::IntoResponse};
use domain::errors::DomainError;
use domain::models::{
AnnotatedRow, FieldMapping, FileFormat,
@@ -39,7 +36,7 @@ use domain::value_objects::ImportSessionId;
pub async fn api_post_session(
State(state): State<AppState>,
AuthenticatedUser(user_id): AuthenticatedUser,
mut multipart: Multipart,
Upload(mut multipart): Upload,
) -> Result<impl IntoResponse, ApiError> {
let mut file_bytes: Option<Vec<u8>> = None;
let mut format_str = "csv".to_string();

View File

@@ -1,15 +1,10 @@
use crate::extractors::Body;
use crate::extractors::{Body, Upload};
use crate::{errors::ApiError, extractors::AuthenticatedUser, state::AppState};
use api_types::{ProfileResponse, UserSummaryDto, UsersResponse};
use application::users::{
get_users, queries::GetUsersQuery, update_profile, update_profile_fields,
};
use axum::{
Json,
extract::{Multipart, State},
http::StatusCode,
response::IntoResponse,
};
use axum::{Json, extract::State, http::StatusCode, response::IntoResponse};
#[utoipa::path(
get, path = "/api/v1/profile",
@@ -66,7 +61,7 @@ pub async fn get_profile(
pub async fn update_profile_handler(
State(state): State<AppState>,
AuthenticatedUser(user_id): AuthenticatedUser,
multipart: Multipart,
Upload(multipart): Upload,
) -> impl IntoResponse {
let data = crate::support::parse_profile_multipart(multipart).await;

View File

@@ -1,4 +1,4 @@
use crate::extractors::{Body, Params, PathId};
use crate::extractors::{Body, Params, PathId, Upload};
use crate::{errors::ApiError, extractors::AuthenticatedUser, state::AppState};
use api_types::{
ConfirmWatchRequest, ConfirmWatchResponse, DismissWatchRequest, DismissWatchResponse,
@@ -17,7 +17,7 @@ use application::integrations::{
};
use axum::{
Json,
extract::{Multipart, State},
extract::State,
http::{HeaderMap, StatusCode},
response::IntoResponse,
};
@@ -98,7 +98,7 @@ pub async fn post_plex_webhook(
State(state): State<AppState>,
headers: HeaderMap,
Params(query): Params<WebhookTokenQuery>,
mut multipart: Multipart,
Upload(mut multipart): Upload,
) -> impl IntoResponse {
let token = match extract_webhook_token(&headers, &query) {
Some(t) => t,

View File

@@ -116,7 +116,7 @@ pub async fn get_status(
get, path = "/api/v1/wrapups/{id}/report",
params(("id" = Uuid, Path, description = "Wrap-up ID")),
responses(
(status = 200, description = "Report JSON", content_type = "application/json"),
(status = 200, description = "Report JSON", body = inline(serde_json::Value)),
(status = 202, description = "Still generating"),
(status = 401, description = "Unauthorized", body = api_types::ErrorResponse),
(status = 404, description = "Not found", body = api_types::ErrorResponse),