Files
arcadia/backend/api/src/handlers/search/search_torrents.rs
FrenchGithubUser af124c9a77 renamed jwt_middleware to auth_middleware, await shared Tracker
struct creation, fix passkeys length
2025-10-14 17:40:12 +02:00

43 lines
1.1 KiB
Rust

use actix_web::{
web::{Data, Json},
HttpResponse,
};
use crate::{middlewares::auth_middleware::Authdata, Arcadia};
use arcadia_common::error::Result;
use arcadia_storage::{
models::torrent::{TorrentSearch, TorrentSearchResults},
redis::RedisPoolInterface,
};
// #[derive(Debug, Deserialize, ToSchema)]
// pub enum SearchPeriod {
// #[serde(rename = "24 hours")]
// TwentyFourHours,
// #[serde(rename = "30 days")]
// ThirtyDays,
// #[serde(rename = "1 year")]
// OneYear,
// #[serde(rename = "all time")]
// AllTime,
// }
#[utoipa::path(
get,
operation_id = "Search torrents",
tag = "Search",
path = "/api/search/torrents/lite",
responses(
(status = 200, description = "Title groups and their torrents found", body=TorrentSearchResults),
)
)]
pub async fn exec<R: RedisPoolInterface + 'static>(
form: Json<TorrentSearch>,
arc: Data<Arcadia<R>>,
user: Authdata,
) -> Result<HttpResponse> {
let search_results = arc.pool.search_torrents(&form, Some(user.sub)).await?;
Ok(HttpResponse::Ok().json(search_results))
}