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:
@@ -3,7 +3,7 @@ use uuid::Uuid;
|
||||
|
||||
use domain::{errors::DomainError, models::RefreshSession, value_objects::Email};
|
||||
|
||||
use crate::auth::{deps::LoginDeps, queries::LoginQuery};
|
||||
use crate::auth::{deps::LoginDeps, queries::LoginCommand};
|
||||
|
||||
pub struct LoginResult {
|
||||
pub token: String,
|
||||
@@ -14,7 +14,7 @@ pub struct LoginResult {
|
||||
pub role: domain::models::UserRole,
|
||||
}
|
||||
|
||||
pub async fn execute(deps: &LoginDeps, query: LoginQuery) -> Result<LoginResult, DomainError> {
|
||||
pub async fn execute(deps: &LoginDeps, query: LoginCommand) -> Result<LoginResult, DomainError> {
|
||||
let email = Email::new(query.email)?;
|
||||
let user = deps
|
||||
.user
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
pub struct LoginQuery {
|
||||
pub struct LoginCommand {
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::auth::{
|
||||
commands::{RegisterAndLoginCommand, RegisterCommand},
|
||||
deps::{LoginDeps, RegisterAndLoginDeps, RegisterDeps},
|
||||
login::{self, LoginResult},
|
||||
queries::LoginQuery,
|
||||
queries::LoginCommand,
|
||||
register,
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ pub async fn execute(
|
||||
};
|
||||
login::execute(
|
||||
&log_deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: cmd.email,
|
||||
password: cmd.password,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
commands::RegisterCommand,
|
||||
deps::{LoginDeps, RegisterDeps},
|
||||
login,
|
||||
queries::LoginQuery,
|
||||
queries::LoginCommand,
|
||||
register,
|
||||
},
|
||||
test_helpers::TestContextBuilder,
|
||||
@@ -48,7 +48,7 @@ async fn test_login_valid_credentials_returns_token() {
|
||||
};
|
||||
let result = login::execute(
|
||||
&deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: "carol@example.com".into(),
|
||||
password: "secret123".into(),
|
||||
},
|
||||
@@ -76,7 +76,7 @@ async fn test_login_wrong_password_fails() {
|
||||
};
|
||||
let result = login::execute(
|
||||
&deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: "dave@example.com".into(),
|
||||
password: "wrong_password".into(),
|
||||
},
|
||||
@@ -98,7 +98,7 @@ async fn test_login_unknown_email_fails() {
|
||||
};
|
||||
let result = login::execute(
|
||||
&deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: "nobody@example.com".into(),
|
||||
password: "anything".into(),
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
commands::RegisterCommand,
|
||||
deps::{LoginDeps, RefreshDeps, RegisterDeps},
|
||||
login, logout,
|
||||
queries::LoginQuery,
|
||||
queries::LoginCommand,
|
||||
refresh, register,
|
||||
},
|
||||
test_helpers::TestContextBuilder,
|
||||
@@ -45,7 +45,7 @@ async fn logout_revokes_refresh_token() {
|
||||
};
|
||||
let login_result = login::execute(
|
||||
&login_deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: "bob@example.com".into(),
|
||||
password: "password123".into(),
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
commands::RegisterCommand,
|
||||
deps::{LoginDeps, RefreshDeps, RegisterDeps},
|
||||
login,
|
||||
queries::LoginQuery,
|
||||
queries::LoginCommand,
|
||||
refresh, register,
|
||||
},
|
||||
test_helpers::TestContextBuilder,
|
||||
@@ -41,7 +41,7 @@ async fn login_user(b: &TestContextBuilder) -> login::LoginResult {
|
||||
};
|
||||
login::execute(
|
||||
&login_deps,
|
||||
LoginQuery {
|
||||
LoginCommand {
|
||||
email: "alice@example.com".into(),
|
||||
password: "password123".into(),
|
||||
},
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::{
|
||||
DiaryEntry, DiaryFilter, SortDirection,
|
||||
DiaryEntry, DiaryFilter, ReviewSortBy,
|
||||
collections::{PageParams, Paginated},
|
||||
},
|
||||
ports::DiaryRepository,
|
||||
@@ -21,7 +21,7 @@ pub async fn execute(
|
||||
let user_id = query.user_id.map(UserId::from_uuid);
|
||||
|
||||
let filter = DiaryFilter {
|
||||
sort_by: query.sort_by.unwrap_or(SortDirection::Descending),
|
||||
sort_by: query.sort_by.unwrap_or(ReviewSortBy::Descending),
|
||||
page,
|
||||
movie_id,
|
||||
user_id: user_id.clone(),
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use domain::models::SortDirection;
|
||||
use domain::models::ReviewSortBy;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct GetDiaryQuery {
|
||||
pub limit: Option<u32>,
|
||||
pub offset: Option<u32>,
|
||||
pub sort_by: Option<SortDirection>,
|
||||
pub sort_by: Option<ReviewSortBy>,
|
||||
pub movie_id: Option<Uuid>,
|
||||
pub user_id: Option<Uuid>,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use domain::{errors::DomainError, events::DomainEvent, value_objects::UserId};
|
||||
|
||||
use crate::users::deps::UpdateProfileDeps;
|
||||
use crate::users::deps::DeleteAccountDeps;
|
||||
|
||||
pub async fn execute(deps: &UpdateProfileDeps, user_id: uuid::Uuid) -> Result<(), DomainError> {
|
||||
pub async fn execute(deps: &DeleteAccountDeps, user_id: uuid::Uuid) -> Result<(), DomainError> {
|
||||
let uid = UserId::from_uuid(user_id);
|
||||
|
||||
deps.user
|
||||
|
||||
@@ -16,3 +16,8 @@ pub struct UpdateProfileDeps {
|
||||
pub object_storage: Arc<dyn ObjectStorage>,
|
||||
pub event_publisher: Arc<dyn EventPublisher>,
|
||||
}
|
||||
|
||||
pub struct DeleteAccountDeps {
|
||||
pub user: Arc<dyn UserRepository>,
|
||||
pub event_publisher: Arc<dyn EventPublisher>,
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use domain::{
|
||||
errors::DomainError,
|
||||
models::FeedSortBy,
|
||||
models::{
|
||||
DiaryEntry, DiaryFilter, SortDirection, UserStats, UserTrends,
|
||||
DiaryEntry, DiaryFilter, ReviewSortBy, UserStats, UserTrends,
|
||||
collections::{PageParams, Paginated},
|
||||
},
|
||||
value_objects::UserId,
|
||||
@@ -108,18 +108,18 @@ async fn load_social_counts(
|
||||
(following, followers, pending)
|
||||
}
|
||||
|
||||
fn feed_sort_to_direction(sort_by: FeedSortBy) -> SortDirection {
|
||||
fn feed_sort_to_direction(sort_by: FeedSortBy) -> ReviewSortBy {
|
||||
match sort_by {
|
||||
FeedSortBy::Date => SortDirection::Descending,
|
||||
FeedSortBy::DateAsc => SortDirection::Ascending,
|
||||
FeedSortBy::Rating => SortDirection::ByRatingDesc,
|
||||
FeedSortBy::RatingAsc => SortDirection::ByRatingAsc,
|
||||
FeedSortBy::Date => ReviewSortBy::Descending,
|
||||
FeedSortBy::DateAsc => ReviewSortBy::Ascending,
|
||||
FeedSortBy::Rating => ReviewSortBy::ByRatingDesc,
|
||||
FeedSortBy::RatingAsc => ReviewSortBy::ByRatingAsc,
|
||||
}
|
||||
}
|
||||
|
||||
fn paged_user_filter(
|
||||
user_id: UserId,
|
||||
sort_by: SortDirection,
|
||||
sort_by: ReviewSortBy,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
search: Option<String>,
|
||||
@@ -149,19 +149,19 @@ mod helper_tests {
|
||||
use domain::models::FeedSortBy;
|
||||
assert!(matches!(
|
||||
feed_sort_to_direction(FeedSortBy::Date),
|
||||
SortDirection::Descending
|
||||
ReviewSortBy::Descending
|
||||
));
|
||||
assert!(matches!(
|
||||
feed_sort_to_direction(FeedSortBy::DateAsc),
|
||||
SortDirection::Ascending
|
||||
ReviewSortBy::Ascending
|
||||
));
|
||||
assert!(matches!(
|
||||
feed_sort_to_direction(FeedSortBy::Rating),
|
||||
SortDirection::ByRatingDesc
|
||||
ReviewSortBy::ByRatingDesc
|
||||
));
|
||||
assert!(matches!(
|
||||
feed_sort_to_direction(FeedSortBy::RatingAsc),
|
||||
SortDirection::ByRatingAsc
|
||||
ReviewSortBy::ByRatingAsc
|
||||
));
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ mod helper_tests {
|
||||
let uid = UserId::from_uuid(uuid::Uuid::new_v4());
|
||||
let filter = paged_user_filter(
|
||||
uid.clone(),
|
||||
SortDirection::Descending,
|
||||
ReviewSortBy::Descending,
|
||||
Some(20),
|
||||
Some(5),
|
||||
Some("blade".into()),
|
||||
|
||||
Reference in New Issue
Block a user