refactor: LOW cleanups — dedup secure_flag, remove vestigial social_query,
drop PersistedImportSession, rename LoginQuery→LoginCommand, own DeleteAccountDeps, PersonId via uuid_id! macro, rename SortDirection→ ReviewSortBy, TUI fs::read→Command, generic PaginatedResponse<T>
This commit is contained in:
@@ -19,7 +19,7 @@ pub fn extract_from_cookie(headers: &axum::http::HeaderMap) -> Option<String> {
|
||||
})
|
||||
}
|
||||
|
||||
fn secure_flag() -> &'static str {
|
||||
pub(crate) fn secure_flag() -> &'static str {
|
||||
if std::env::var("SECURE_COOKIES").as_deref() == Ok("true") {
|
||||
"; Secure"
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ use application::diary::{
|
||||
commands::{LogReviewCommand, MovieInput},
|
||||
queries::GetDiaryQuery,
|
||||
};
|
||||
use domain::{errors::DomainError, models::SortDirection};
|
||||
use domain::{errors::DomainError, models::ReviewSortBy};
|
||||
|
||||
use api_types::{DiaryQueryParams, LogReviewRequest};
|
||||
|
||||
@@ -258,10 +258,10 @@ pub fn to_diary_query(p: DiaryQueryParams) -> GetDiaryQuery {
|
||||
limit: p.limit,
|
||||
offset: p.offset,
|
||||
sort_by: p.sort_by.as_deref().map(|s| match s {
|
||||
"date_asc" | "asc" => SortDirection::Ascending,
|
||||
"rating_desc" => SortDirection::ByRatingDesc,
|
||||
"rating_asc" => SortDirection::ByRatingAsc,
|
||||
_ => SortDirection::Descending,
|
||||
"date_asc" | "asc" => ReviewSortBy::Ascending,
|
||||
"rating_desc" => ReviewSortBy::ByRatingDesc,
|
||||
"rating_asc" => ReviewSortBy::ByRatingAsc,
|
||||
_ => ReviewSortBy::Descending,
|
||||
}),
|
||||
movie_id: p.movie_id,
|
||||
user_id: p.user_id,
|
||||
|
||||
@@ -10,12 +10,12 @@ use application::auth::{
|
||||
commands::RegisterCommand,
|
||||
deps::{LoginDeps, RefreshDeps, RegisterAndLoginDeps, RegisterDeps},
|
||||
login as login_uc,
|
||||
queries::LoginQuery,
|
||||
queries::LoginCommand,
|
||||
register as register_uc,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
csrf::CsrfToken,
|
||||
csrf::{CsrfToken, secure_flag},
|
||||
errors::ApiError,
|
||||
forms::{ErrorQuery, LoginForm, RegisterForm},
|
||||
render::render_page,
|
||||
@@ -29,14 +29,6 @@ use template_askama::{LoginTemplate, RegisterTemplate};
|
||||
|
||||
// ── HTML helpers ─────────────────────────────────────────────────────────────
|
||||
|
||||
fn secure_flag() -> &'static str {
|
||||
if std::env::var("SECURE_COOKIES").as_deref() == Ok("true") {
|
||||
"; Secure"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
fn set_cookie_header(token: &str, max_age: i64) -> (axum::http::HeaderName, HeaderValue) {
|
||||
let val = format!(
|
||||
"token={}; HttpOnly; Path=/; SameSite=Strict; Max-Age={}{}",
|
||||
@@ -73,7 +65,7 @@ pub async fn login(
|
||||
};
|
||||
let result = login_uc::execute(
|
||||
&deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: req.email,
|
||||
password: req.password,
|
||||
},
|
||||
@@ -204,7 +196,7 @@ pub async fn post_login(
|
||||
};
|
||||
match login_uc::execute(
|
||||
&deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: form.email,
|
||||
password: form.password,
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ use axum::{
|
||||
use uuid::Uuid;
|
||||
|
||||
use application::{diary::get_diary, diary::queries::GetDiaryQuery};
|
||||
use domain::{errors::DomainError, models::SortDirection, value_objects::UserId};
|
||||
use domain::{errors::DomainError, models::ReviewSortBy, value_objects::UserId};
|
||||
|
||||
use crate::{errors::ApiError, state::AppState};
|
||||
|
||||
@@ -14,7 +14,7 @@ pub async fn get_feed(State(state): State<AppState>) -> Result<impl IntoResponse
|
||||
let query = GetDiaryQuery {
|
||||
limit: Some(super::RSS_FEED_LIMIT),
|
||||
offset: Some(0),
|
||||
sort_by: Some(SortDirection::Descending),
|
||||
sort_by: Some(ReviewSortBy::Descending),
|
||||
movie_id: None,
|
||||
user_id: None,
|
||||
};
|
||||
@@ -45,7 +45,7 @@ pub async fn get_user_feed(
|
||||
let query = GetDiaryQuery {
|
||||
limit: Some(super::RSS_FEED_LIMIT),
|
||||
offset: Some(0),
|
||||
sort_by: Some(SortDirection::Descending),
|
||||
sort_by: Some(ReviewSortBy::Descending),
|
||||
movie_id: None,
|
||||
user_id: Some(user_id),
|
||||
};
|
||||
|
||||
@@ -209,8 +209,6 @@ async fn wire_dependencies() -> anyhow::Result<(AppState, axum::Router)> {
|
||||
)),
|
||||
#[cfg(feature = "federation")]
|
||||
ap_service,
|
||||
#[cfg(feature = "federation")]
|
||||
social_query,
|
||||
};
|
||||
Ok((state, ap_router))
|
||||
}
|
||||
|
||||
@@ -10,6 +10,4 @@ pub struct AppState {
|
||||
pub rss_renderer: Arc<dyn RssFeedRenderer>,
|
||||
#[cfg(feature = "federation")]
|
||||
pub ap_service: Arc<dyn activitypub::ActivityPubPort>,
|
||||
#[cfg(feature = "federation")]
|
||||
pub social_query: Arc<dyn domain::ports::SocialQueryPort>,
|
||||
}
|
||||
|
||||
@@ -843,8 +843,6 @@ pub fn make_test_state(auth_service: Arc<dyn AuthService>) -> crate::state::AppS
|
||||
rss_renderer: Arc::new(Panic),
|
||||
#[cfg(feature = "federation")]
|
||||
ap_service: Arc::new(activitypub::NoopActivityPubService),
|
||||
#[cfg(feature = "federation")]
|
||||
social_query: Arc::new(Panic),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ fn sort_by_asc_string_becomes_ascending() {
|
||||
let query = to_diary_query(params);
|
||||
assert!(matches!(
|
||||
query.sort_by,
|
||||
Some(domain::models::SortDirection::Ascending)
|
||||
Some(domain::models::ReviewSortBy::Ascending)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ fn sort_by_other_string_becomes_descending() {
|
||||
let query = to_diary_query(params);
|
||||
assert!(matches!(
|
||||
query.sort_by,
|
||||
Some(domain::models::SortDirection::Descending)
|
||||
Some(domain::models::ReviewSortBy::Descending)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -500,8 +500,6 @@ async fn test_app() -> Router {
|
||||
rss_renderer: Arc::new(RssAdapter::new("http://localhost:3000".into())),
|
||||
#[cfg(feature = "federation")]
|
||||
ap_service: Arc::new(activitypub::NoopActivityPubService),
|
||||
#[cfg(feature = "federation")]
|
||||
social_query: Arc::new(PanicSocialQuery),
|
||||
};
|
||||
|
||||
routes::build_router(state, axum::Router::new())
|
||||
|
||||
Reference in New Issue
Block a user