From 78642dcae386991e008f30e238b4c31dea73ce2a Mon Sep 17 00:00:00 2001 From: Banjo Fox Date: Wed, 30 Aug 2023 14:40:31 -0400 Subject: [PATCH 1/3] Run `cargo clippy --fix --lib -p aardwolf-models` --- aardwolf-models/src/base_post.rs | 2 +- aardwolf-models/src/sql_types/mime.rs | 2 +- aardwolf-models/src/user/email/token.rs | 2 +- aardwolf-models/src/user/local_auth/password.rs | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aardwolf-models/src/base_post.rs b/aardwolf-models/src/base_post.rs index 20e85dbb..34c8f3eb 100644 --- a/aardwolf-models/src/base_post.rs +++ b/aardwolf-models/src/base_post.rs @@ -121,7 +121,7 @@ impl NewBasePost { posted_by: posted_by.id(), icon: icon.map(|i| i.id()), visibility, - activitypub_id: generate_id.post_id(&posted_by, &uuid), + activitypub_id: generate_id.post_id(posted_by, &uuid), local_uuid: Some(uuid), } } diff --git a/aardwolf-models/src/sql_types/mime.rs b/aardwolf-models/src/sql_types/mime.rs index 87215b0e..6500a969 100644 --- a/aardwolf-models/src/sql_types/mime.rs +++ b/aardwolf-models/src/sql_types/mime.rs @@ -65,7 +65,7 @@ impl Serialize for Mime { where S: Serializer, { - serializer.serialize_str(&self.to_string()) + serializer.serialize_str(self.as_ref()) } } diff --git a/aardwolf-models/src/user/email/token.rs b/aardwolf-models/src/user/email/token.rs index 0c277b8d..fb25170b 100644 --- a/aardwolf-models/src/user/email/token.rs +++ b/aardwolf-models/src/user/email/token.rs @@ -101,7 +101,7 @@ impl VerifyEmail for HashedEmailToken { &self, email_verification_token: EmailVerificationToken, ) -> Result<(), VerificationError> { - verify(&email_verification_token.0, &self.0) + verify(email_verification_token.0, &self.0) .map_err(|_| VerificationError::Process) .and_then(|verified| { if verified { diff --git a/aardwolf-models/src/user/local_auth/password.rs b/aardwolf-models/src/user/local_auth/password.rs index cac3c3a4..abf1f693 100644 --- a/aardwolf-models/src/user/local_auth/password.rs +++ b/aardwolf-models/src/user/local_auth/password.rs @@ -234,7 +234,7 @@ impl fmt::Display for Password { impl Verify for Password { fn verify(&self, given_password: PlaintextPassword) -> Result<(), VerificationError> { - verify(&given_password.0, &self.0) + verify(given_password.0, &self.0) .map_err(|e| { error!("Error verifying password: {}", e); @@ -256,7 +256,7 @@ impl Create for Password { warn!("BUILT IN TEST MODE"); #[cfg(not(any(test, feature = "test")))] - let h = hash(&password.0, bcrypt::DEFAULT_COST); + let h = hash(password.0, bcrypt::DEFAULT_COST); #[cfg(any(test, feature = "test"))] let h = hash(&password.0, 4); From ee4ff163797a83edaf908f644ceb40d1500c9654 Mon Sep 17 00:00:00 2001 From: Banjo Fox Date: Wed, 30 Aug 2023 14:50:58 -0400 Subject: [PATCH 2/3] Removing unecessary `drop(user);` --- aardwolf-models/Cargo.toml | 1 - aardwolf-models/src/user/email.rs | 2 -- aardwolf-models/src/user/local_auth.rs | 2 -- 3 files changed, 5 deletions(-) diff --git a/aardwolf-models/Cargo.toml b/aardwolf-models/Cargo.toml index 138e21e0..f1c32469 100644 --- a/aardwolf-models/Cargo.toml +++ b/aardwolf-models/Cargo.toml @@ -22,7 +22,6 @@ thiserror = "1.0" url = "2.1" dotenvy ="0.15" - [dependencies.uuid] version = "1.3" features = ["v4"] diff --git a/aardwolf-models/src/user/email.rs b/aardwolf-models/src/user/email.rs index a7fcb6a8..e8202d7b 100644 --- a/aardwolf-models/src/user/email.rs +++ b/aardwolf-models/src/user/email.rs @@ -201,8 +201,6 @@ impl UnverifiedEmail { ) }); - drop(user); - res } diff --git a/aardwolf-models/src/user/local_auth.rs b/aardwolf-models/src/user/local_auth.rs index 509a0acc..b927abb0 100644 --- a/aardwolf-models/src/user/local_auth.rs +++ b/aardwolf-models/src/user/local_auth.rs @@ -68,8 +68,6 @@ impl LocalAuth { updated_at: user.updated_at, }); - drop(user); - res } } From e67fa3941c2dac588fa771e551afe6bc90be86e9 Mon Sep 17 00:00:00 2001 From: Banjo Fox Date: Wed, 30 Aug 2023 14:51:43 -0400 Subject: [PATCH 3/3] Apply a round of clippy auto-fixes --- aardwolf-models/src/user/email.rs | 8 ++++---- aardwolf-models/src/user/local_auth.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/aardwolf-models/src/user/email.rs b/aardwolf-models/src/user/email.rs index e8202d7b..2d7b5ed6 100644 --- a/aardwolf-models/src/user/email.rs +++ b/aardwolf-models/src/user/email.rs @@ -188,7 +188,9 @@ impl UnverifiedEmail { user: UnverifiedUser, token: EmailVerificationToken, ) -> Result<(AuthenticatedUser, VerifyEmail), VerificationError> { - let res = self.verify(token).map(|verify_email| { + + + self.verify(token).map(|verify_email| { ( AuthenticatedUser { id: user.id, @@ -199,9 +201,7 @@ impl UnverifiedEmail { }, verify_email, ) - }); - - res + }) } pub fn verify(self, token: EmailVerificationToken) -> Result { diff --git a/aardwolf-models/src/user/local_auth.rs b/aardwolf-models/src/user/local_auth.rs index b927abb0..b969a1e0 100644 --- a/aardwolf-models/src/user/local_auth.rs +++ b/aardwolf-models/src/user/local_auth.rs @@ -60,15 +60,15 @@ impl LocalAuth { return Err(VerificationError::Process); } - let res = self.password.verify(password).map(|_| AuthenticatedUser { + + + self.password.verify(password).map(|_| AuthenticatedUser { id: user.id, primary_email: user.primary_email, primary_persona: user.primary_persona, created_at: user.created_at, updated_at: user.updated_at, - }); - - res + }) } }