From c91eaa8dd26375feb59e4af79ca8b378fc7c9c62 Mon Sep 17 00:00:00 2001 From: Mari Date: Sat, 4 Oct 2025 06:32:14 +0200 Subject: [PATCH] fix most clippys --- gitarena-common/src/ipc.rs | 2 +- gitarena-common/src/log.rs | 4 ++-- gitarena-workhorse/src/main.rs | 2 +- src/git/history.rs | 2 +- src/git/io/writer.rs | 2 +- src/main.rs | 7 ++---- src/prelude.rs | 2 +- src/privileges/privilege.rs | 4 ++-- src/repository.rs | 4 ++-- src/routes/admin/dashboard.rs | 2 +- src/routes/repository/api/create_repo.rs | 6 ++--- src/routes/repository/api/fork_repo.rs | 6 ++--- src/routes/repository/api/import_repo.rs | 6 ++--- src/routes/repository/blobs/blob.rs | 11 +-------- src/routes/repository/blobs/directory.rs | 23 +++++-------------- src/routes/repository/commits.rs | 4 ++-- src/routes/repository/git/git_receive_pack.rs | 4 ++-- src/routes/repository/issues.rs | 4 ++-- src/routes/repository/repo_view.rs | 5 ++-- src/routes/user/api/add_key.rs | 4 ++-- src/routes/user/avatar.rs | 4 ++-- src/routes/user/sso.rs | 2 +- src/routes/user/user_create.rs | 2 +- src/routes/user/user_verify.rs | 6 ++--- src/session.rs | 12 +++++----- src/sso/bitbucket_sso.rs | 6 ++--- src/sso/github_sso.rs | 8 +++---- src/sso/gitlab_sso.rs | 6 ++--- src/templates/filters.rs | 2 +- src/templates/mod.rs | 2 +- src/user.rs | 2 +- src/verification.rs | 2 +- 32 files changed, 67 insertions(+), 91 deletions(-) diff --git a/gitarena-common/src/ipc.rs b/gitarena-common/src/ipc.rs index f374921..96b7a37 100644 --- a/gitarena-common/src/ipc.rs +++ b/gitarena-common/src/ipc.rs @@ -80,7 +80,7 @@ impl<'a, T: Deserialize<'a>> IpcPacket { } } -impl IpcPacket { +impl IpcPacket { pub fn deserialize_from(input: R) -> bincode::Result { Self::bincode().deserialize_from::<_, Self>(input) } diff --git a/gitarena-common/src/log.rs b/gitarena-common/src/log.rs index 89c04c9..a050c98 100644 --- a/gitarena-common/src/log.rs +++ b/gitarena-common/src/log.rs @@ -9,12 +9,12 @@ use tracing::metadata::LevelFilter; use tracing::Subscriber; use tracing_appender::non_blocking::WorkerGuard; use tracing_appender::rolling; -use tracing_subscriber::filter::{FilterExt, FromEnvError}; +use tracing_subscriber::filter::FromEnvError; use tracing_subscriber::fmt::Layer; use tracing_subscriber::layer::SubscriberExt; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{layer, EnvFilter, Layer as RootLayer, Registry}; +use tracing_subscriber::{layer, EnvFilter, Registry}; use tracing_unwrap::ResultExt; pub fn init_logger( diff --git a/gitarena-workhorse/src/main.rs b/gitarena-workhorse/src/main.rs index d921a47..3ff0fce 100644 --- a/gitarena-workhorse/src/main.rs +++ b/gitarena-workhorse/src/main.rs @@ -15,7 +15,7 @@ use tracing_unwrap::ResultExt; #[tokio::main] async fn main() -> Result<()> { - let _log_guards = init_logger("gitarena-workhorse", &[])?; + let _log_guards = init_logger("gitarena-workhorse", &[], None)?; Endpoint::new(ipc_path()?.to_owned()) .incoming() diff --git a/src/git/history.rs b/src/git/history.rs index b4c3646..d4cb974 100644 --- a/src/git/history.rs +++ b/src/git/history.rs @@ -11,7 +11,7 @@ pub(crate) async fn last_commit_for_blob( ) -> Result> { let commits = commits_for_blob(repo, reference_name, file_name, Some(1)).await?; - Ok(commits.get(0).copied()) + Ok(commits.first().copied()) } #[instrument(err, skip(repo))] diff --git a/src/git/io/writer.rs b/src/git/io/writer.rs index 6242a88..a31e16a 100644 --- a/src/git/io/writer.rs +++ b/src/git/io/writer.rs @@ -182,6 +182,6 @@ impl GitWriter { fn u16_to_hex(value: u16) -> [u8; 4] { let mut buffer = [0u8; 4]; - hex::encode_to_slice((value as u16).to_be_bytes(), &mut buffer).unwrap_or_log(); + hex::encode_to_slice(value.to_be_bytes(), &mut buffer).unwrap_or_log(); buffer } diff --git a/src/main.rs b/src/main.rs index 9fbabef..b977d4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,15 +23,12 @@ use actix_web::{App, HttpResponse, HttpServer}; use anyhow::{anyhow, Context, Result}; use futures_locks::RwLock; use gitarena_common::database::create_postgres_pool; -use gitarena_common::log::{default_env, init_logger, log_file, stdout, tokio_console}; +use gitarena_common::log::init_logger; use gitarena_macros::from_optional_config; use log::info; use magic::{Cookie, CookieFlags}; use time::Duration as TimeDuration; -use tracing_appender::non_blocking::WorkerGuard; -use tracing_subscriber::layer::SubscriberExt; -use tracing_subscriber::util::SubscriberInitExt; -use tracing_subscriber::{EnvFilter, Layer, Registry}; +use tracing_subscriber::Layer; use tracing_unwrap::ResultExt; mod captcha; diff --git a/src/prelude.rs b/src/prelude.rs index e8e175b..2b5fb69 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -204,7 +204,7 @@ impl GitoxideSignatureExtensions for GitoxideSignature { name: BString::from("GitArena"), // TODO: Allow administrators to edit this email: BString::from("git@gitarena.com"), // as well as this time: GitoxideTime { - time: naive.timestamp() as u32, + time: naive.and_utc().timestamp() as u32, offset: 0, sign: Sign::Plus, }, diff --git a/src/privileges/privilege.rs b/src/privileges/privilege.rs index 640e4d9..363e0e4 100644 --- a/src/privileges/privilege.rs +++ b/src/privileges/privilege.rs @@ -88,8 +88,8 @@ async fn get_repo_privilege<'e, E: Executor<'e, Database = Postgres>>( Ok(sqlx::query_as::<_, Privilege>( "select * from privileges where user_id = $1 and repo_id = $2 limit 1", ) - .bind(&user.id) - .bind(&repo.id) + .bind(user.id) + .bind(repo.id) .fetch_optional(executor) .await?) } diff --git a/src/repository.rs b/src/repository.rs index e0a8c7e..bbea58a 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -60,7 +60,7 @@ impl Repository { let repo: Option = sqlx::query_as::<_, Repository>( "select * from repositories where owner = $1 and lower(name) = lower($2) limit 1", ) - .bind(&user_id) + .bind(user_id) .bind(repo_name) .fetch_optional(executor) .await @@ -111,7 +111,7 @@ impl Repository { cross join \ (select username from users where id = $1 limit 1) B", ) - .bind(&self.owner) + .bind(self.owner) .fetch_one(executor) .await?; diff --git a/src/routes/admin/dashboard.rs b/src/routes/admin/dashboard.rs index 6f2be39..30cb255 100644 --- a/src/routes/admin/dashboard.rs +++ b/src/routes/admin/dashboard.rs @@ -73,7 +73,7 @@ pub(crate) async fn dashboard( let (latest_repo_username_option,): (String,) = sqlx::query_as("select username from users where id = $1 limit 1") - .bind(&latest_repo.owner) + .bind(latest_repo.owner) .fetch_one(&mut transaction) .await?; diff --git a/src/routes/repository/api/create_repo.rs b/src/routes/repository/api/create_repo.rs index a4a6561..104a23f 100644 --- a/src/routes/repository/api/create_repo.rs +++ b/src/routes/repository/api/create_repo.rs @@ -52,8 +52,8 @@ pub(crate) async fn create( } let (exists,): (bool,) = sqlx::query_as("select exists(select 1 from repositories where owner = $1 and lower(name) = lower($2) limit 1)") - .bind(&user.id) - .bind(&name) + .bind(user.id) + .bind(name) .fetch_one(&mut transaction) .await?; @@ -62,7 +62,7 @@ pub(crate) async fn create( } let repo: Repository = sqlx::query_as::<_, Repository>("insert into repositories (owner, name, description, visibility) values ($1, $2, $3, $4) returning *") - .bind(&user.id) + .bind(user.id) .bind(name) .bind(description) .bind(&body.visibility) diff --git a/src/routes/repository/api/fork_repo.rs b/src/routes/repository/api/fork_repo.rs index b075c9a..ff6a53b 100644 --- a/src/routes/repository/api/fork_repo.rs +++ b/src/routes/repository/api/fork_repo.rs @@ -78,7 +78,7 @@ pub(crate) async fn create_fork( } let (exists,): (bool,) = sqlx::query_as("select exists(select 1 from repositories where owner = $1 and lower(name) = lower($2) limit 1)") - .bind(&user.id) + .bind(user.id) .bind(&repo.name) .fetch_one(&mut transaction) .await?; @@ -88,11 +88,11 @@ pub(crate) async fn create_fork( } let new_repo = sqlx::query_as::<_, Repository>("insert into repositories (owner, name, description, visibility, forked_from) values ($1, $2, $3, $4, $5) returning *") - .bind(&user.id) + .bind(user.id) .bind(&repo.name) .bind(&repo.description) .bind(&repo.visibility) - .bind(&repo.id) + .bind(repo.id) .fetch_one(&mut transaction) .await?; diff --git a/src/routes/repository/api/import_repo.rs b/src/routes/repository/api/import_repo.rs index 4e6fba3..e975407 100644 --- a/src/routes/repository/api/import_repo.rs +++ b/src/routes/repository/api/import_repo.rs @@ -68,8 +68,8 @@ pub(crate) async fn import( } let (exists,): (bool,) = sqlx::query_as("select exists(select 1 from repositories where owner = $1 and lower(name) = lower($2) limit 1)") - .bind(&user.id) - .bind(&name) + .bind(user.id) + .bind(name) .fetch_one(&mut transaction) .await?; @@ -78,7 +78,7 @@ pub(crate) async fn import( } let repo: Repository = sqlx::query_as::<_, Repository>("insert into repositories (owner, name, description, visibility) values ($1, $2, $3, $4) returning *") - .bind(&user.id) + .bind(user.id) .bind(name) .bind(description) .bind(&body.visibility) diff --git a/src/routes/repository/blobs/blob.rs b/src/routes/repository/blobs/blob.rs index 309696c..c825bf2 100644 --- a/src/routes/repository/blobs/blob.rs +++ b/src/routes/repository/blobs/blob.rs @@ -19,8 +19,6 @@ use git_repository::objs::tree::EntryMode; use git_repository::objs::{Tree, TreeRef}; use git_repository::odb::pack::FindExt; use git_repository::odb::Store; -use git_repository::refs::file::loose::Reference; -use git_repository::Repository as GitoxideRepository; use gitarena_macros::route; use magic::Cookie; use sqlx::PgPool; @@ -60,10 +58,8 @@ pub(crate) async fn view_blob( ) .await?; let (name, content, mode) = recursively_visit_blob_content( - &branch.reference, tree_ref, uri.blob.as_str(), - &gitoxide_repo, store.clone(), &mut blob_buffer, ) @@ -150,10 +146,8 @@ pub(crate) async fn view_raw_blob( ) .await?; let (_, content, _) = recursively_visit_blob_content( - &branch.reference, tree_ref, uri.blob.as_str(), - &gitoxide_repo, store.clone(), &mut blob_buffer, ) @@ -177,10 +171,8 @@ pub(crate) async fn view_raw_blob( #[async_recursion(?Send)] async fn recursively_visit_blob_content<'a>( - reference: &Reference, tree_ref: TreeRef<'a>, path: &str, - repo: &'a GitoxideRepository, store: Arc, buffer: &'a mut Vec, ) -> Result<(String, String, EntryMode)> { @@ -207,8 +199,7 @@ async fn recursively_visit_blob_content<'a>( .map(|(tree, _)| tree)?; let mut buffer = Vec::::new(); - recursively_visit_blob_content(reference, tree_ref, remaining, repo, store, &mut buffer) - .await + recursively_visit_blob_content(tree_ref, remaining, store, &mut buffer).await } None => { if entry.mode != EntryMode::Blob && entry.mode != EntryMode::BlobExecutable { diff --git a/src/routes/repository/blobs/directory.rs b/src/routes/repository/blobs/directory.rs index 39c8449..3481bb0 100644 --- a/src/routes/repository/blobs/directory.rs +++ b/src/routes/repository/blobs/directory.rs @@ -21,8 +21,7 @@ use git_repository::objs::tree::EntryMode; use git_repository::objs::{Tree, TreeRef}; use git_repository::odb::pack::FindExt; use git_repository::odb::Store; -use git_repository::refs::file::loose::Reference; -use git_repository::{ObjectId, Repository as GitoxideRepository}; +use git_repository::ObjectId; use gitarena_macros::route; use sqlx::PgPool; use tera::Context; @@ -61,20 +60,13 @@ pub(crate) async fn view_dir( &mut tree_ref_buffer, ) .await?; - let tree = recursively_visit_tree( - &branch.reference, - tree_ref, - path.as_str(), - &gitoxide_repo, - store.clone(), - &mut tree_buffer, - ) - .await?; + let tree = + recursively_visit_tree(tree_ref, path.as_str(), store.clone(), &mut tree_buffer).await?; let (issues_count,): (i64,) = sqlx::query_as( "select count(*) from issues where repo = $1 and closed = false and confidential = false", ) - .bind(&repo.id) + .bind(repo.id) .fetch_one(&mut transaction) .await?; @@ -92,8 +84,7 @@ pub(crate) async fn view_dir( // Should be generalized so we don't have this code twice but can re-use it in repo_view and here in directory - let mut files = Vec::::new(); - files.reserve(tree.entries.len().min(1000)); + let mut files = Vec::::with_capacity(tree.entries.len().min(1000)); for entry in tree.entries.iter().take(1000) { let name = entry.filename.to_str().unwrap_or("Invalid file name"); @@ -194,10 +185,8 @@ pub(crate) async fn view_dir( #[async_recursion(?Send)] async fn recursively_visit_tree<'a>( - reference: &Reference, tree_ref: TreeRef<'a>, path: &str, - repo: &'a GitoxideRepository, store: Arc, buffer: &'a mut Vec, ) -> Result { @@ -221,7 +210,7 @@ async fn recursively_visit_tree<'a>( .map(|(tree, _)| tree)?; let mut buffer = Vec::::new(); - recursively_visit_tree(reference, tree_ref, remaining, repo, store, &mut buffer).await + recursively_visit_tree(tree_ref, remaining, store, &mut buffer).await } None => Ok(tree), } diff --git a/src/routes/repository/commits.rs b/src/routes/repository/commits.rs index 43cc3ec..cd2608b 100644 --- a/src/routes/repository/commits.rs +++ b/src/routes/repository/commits.rs @@ -59,13 +59,13 @@ pub(crate) async fn commits( let chrono_time = commit.time().try_as_chrono()?; let chrono_date = chrono_time.date(); - let chrono_time_only_date = chrono_date.and_hms(0, 0, 0); + let chrono_time_only_date = chrono_date.and_hms_opt(0, 0, 0); commits.push(GitCommit { oid: format!("{}", commit.id()), message: commit.message().unwrap_or_default().to_owned(), time: commit.time().seconds(), - date: Some(chrono_time_only_date), + date: chrono_time_only_date, author_name: name, author_uid: uid, author_email: email, diff --git a/src/routes/repository/git/git_receive_pack.rs b/src/routes/repository/git/git_receive_pack.rs index a3cdc04..fd57653 100644 --- a/src/routes/repository/git/git_receive_pack.rs +++ b/src/routes/repository/git/git_receive_pack.rs @@ -184,7 +184,7 @@ pub(crate) async fn git_receive_pack( // Let Git collect garbage to optimize repo size let command = Command::new("git") - .args(&["gc", "--auto", "--quiet"]) + .args(["gc", "--auto", "--quiet"]) .current_dir(repo_dir) .kill_on_drop(true) .stdout(Stdio::null()) @@ -219,7 +219,7 @@ pub(crate) async fn git_receive_pack( sqlx::query("update repositories set license = $1 where id = $2") .bind(&repo.license) - .bind(&repo.id) + .bind(repo.id) .execute(&mut transaction) .await?; diff --git a/src/routes/repository/issues.rs b/src/routes/repository/issues.rs index b7488c5..027a6b3 100644 --- a/src/routes/repository/issues.rs +++ b/src/routes/repository/issues.rs @@ -38,7 +38,7 @@ pub(crate) async fn all_issues( ) .as_str(), ) - .bind(&repo.id) + .bind(repo.id) .fetch_all(&mut transaction) .await?; @@ -49,7 +49,7 @@ pub(crate) async fn all_issues( for issue in issues.iter() { let (username,): (String,) = sqlx::query_as("select username from users where id = $1 limit 1") - .bind(&issue.author) + .bind(issue.author) .fetch_one(&mut transaction) .await?; diff --git a/src/routes/repository/repo_view.rs b/src/routes/repository/repo_view.rs index 7a06f32..b8e593d 100644 --- a/src/routes/repository/repo_view.rs +++ b/src/routes/repository/repo_view.rs @@ -41,7 +41,7 @@ async fn render( let (issues_count,): (i64,) = sqlx::query_as( "select count(*) from issues where repo = $1 and closed = false and confidential = false", ) - .bind(&repo.id) + .bind(repo.id) .fetch_one(&mut transaction) .await?; @@ -80,8 +80,7 @@ async fn render( let tree = repo_files_at_ref(&loose_ref, store.clone(), &gitoxide_repo, &mut buffer).await?; let tree = Tree::from(tree); - let mut files = Vec::::new(); - files.reserve(tree.entries.len().min(1000)); + let mut files = Vec::::with_capacity(tree.entries.len().min(1000)); for entry in tree.entries.iter().take(1000) { let name = entry.filename.to_str().unwrap_or("Invalid file name"); diff --git a/src/routes/user/api/add_key.rs b/src/routes/user/api/add_key.rs index e16ad3f..bdf5b67 100644 --- a/src/routes/user/api/add_key.rs +++ b/src/routes/user/api/add_key.rs @@ -65,12 +65,12 @@ pub(crate) async fn put_ssh_key( } let key = sqlx::query_as::<_, SshKey>("insert into ssh_keys (owner, title, fingerprint, algorithm, key, expires_at) values ($1, $2, $3, $4, $5, $6) returning *") - .bind(&user.id) + .bind(user.id) .bind(key_title) .bind(fingerprint.as_str()) .bind(algorithm) .bind(public_key.data().as_slice()) - .bind(&body.expiration_date) + .bind(body.expiration_date) .fetch_one(&mut transaction) .await?; diff --git a/src/routes/user/avatar.rs b/src/routes/user/avatar.rs index d815bb5..37cafea 100644 --- a/src/routes/user/avatar.rs +++ b/src/routes/user/avatar.rs @@ -70,9 +70,9 @@ pub(crate) async fn get_avatar( let path_str = format!("{}/default.jpg", avatars_dir); let path = Path::new(path_str.as_str()); - Ok(send_image(path, &request) + send_image(path, &request) .await - .context("Failed to read default avatar file")?) + .context("Failed to read default avatar file") } #[route("/api/avatar", method = "PUT", err = "text")] diff --git a/src/routes/user/sso.rs b/src/routes/user/sso.rs index 221531a..25b6bc7 100644 --- a/src/routes/user/sso.rs +++ b/src/routes/user/sso.rs @@ -86,7 +86,7 @@ pub(crate) async fn sso_callback( Some(sso) => { // User link already exists -> Login user sqlx::query_as::<_, User>("select * from users where id = $1 limit 1") - .bind(&sso.user_id) + .bind(sso.user_id) .fetch_one(&mut transaction) .await? } diff --git a/src/routes/user/user_create.rs b/src/routes/user/user_create.rs index a659626..6f60b8e 100644 --- a/src/routes/user/user_create.rs +++ b/src/routes/user/user_create.rs @@ -127,7 +127,7 @@ pub(crate) async fn post_register( .await?; sqlx::query("insert into emails (owner, email, \"primary\", commit, notification, public) values ($1, $2, true, true, true, true)") - .bind(&user.id) + .bind(user.id) .bind(email) .execute(&mut transaction) .await?; diff --git a/src/routes/user/user_verify.rs b/src/routes/user/user_verify.rs index 4d3aa9f..7b5fb70 100644 --- a/src/routes/user/user_verify.rs +++ b/src/routes/user/user_verify.rs @@ -25,7 +25,7 @@ pub(crate) async fn verify( let option: Option<(i32, i32)> = sqlx::query_as( "select id, user_id from user_verifications where hash = $1 and expires > now() limit 1", ) - .bind(&token) + .bind(token) .fetch_optional(&mut transaction) .await?; @@ -36,12 +36,12 @@ pub(crate) async fn verify( let (row_id, user_id) = option.unwrap_or_log(); sqlx::query("update emails set verified_at = current_timestamp where owner = $1") - .bind(&user_id) + .bind(user_id) .execute(&mut transaction) .await?; sqlx::query("delete from user_verifications where id = $1") - .bind(&row_id) + .bind(row_id) .execute(&mut transaction) .await?; diff --git a/src/session.rs b/src/session.rs index 4c0a2d5..e098087 100644 --- a/src/session.rs +++ b/src/session.rs @@ -44,8 +44,8 @@ impl Session { let user_agent = user_agent.chars().take(256).collect::(); let repo: Session = sqlx::query_as::<_, Session>("insert into sessions (user_id, ip_address, user_agent) values ($1, $2, $3) returning *") - .bind(&user.id) - .bind(&ip_address) + .bind(user.id) + .bind(ip_address) .bind(&user_agent) .fetch_one(executor) .await?; @@ -91,10 +91,10 @@ impl Session { let user_agent = user_agent.chars().take(256).collect::(); sqlx::query("update sessions set ip_address = $1, user_agent = $2, updated_at = $3 where user_id = $4 and hash = $5") - .bind(&ip_address) + .bind(ip_address) .bind(&user_agent) - .bind(&now) - .bind(&self.user_id) + .bind(now) + .bind(self.user_id) .bind(self.hash.as_str()) .execute(executor) .await?; @@ -120,7 +120,7 @@ impl Session { executor: E, ) -> Result<()> { sqlx::query("delete from sessions where user_id = $1 and hash = $2") - .bind(&self.user_id) + .bind(self.user_id) .bind(self.hash.as_str()) .execute(executor) .await?; diff --git a/src/sso/bitbucket_sso.rs b/src/sso/bitbucket_sso.rs index cfbb128..5c624ba 100644 --- a/src/sso/bitbucket_sso.rs +++ b/src/sso/bitbucket_sso.rs @@ -139,7 +139,7 @@ impl SSOProvider for BitBucketSSO { .ok_or_else(|| anyhow!("Failed to retrieve id from BitBucket API json response"))?; sqlx::query("insert into sso (user_id, provider, provider_id) values ($1, $2, $3)") - .bind(&user.id) + .bind(user.id) .bind(&SSOProviderType::BitBucket) .bind(bitbucket_id.as_str()) .execute(&mut transaction) @@ -176,9 +176,9 @@ impl SSOProvider for BitBucketSSO { // All email addresses have already been verified by Bitbucket, so we also mark them as verified sqlx::query("insert into emails (owner, email, \"primary\", commit, notification, public, verified_at) values ($1, $2, $3, $3, $3, $3, current_timestamp)") - .bind(&user.id) + .bind(user.id) .bind(email) - .bind(&primary) + .bind(primary) .execute(&mut transaction) .await?; } diff --git a/src/sso/github_sso.rs b/src/sso/github_sso.rs index 2d6cedd..da38576 100644 --- a/src/sso/github_sso.rs +++ b/src/sso/github_sso.rs @@ -157,7 +157,7 @@ impl SSOProvider for GitHubSSO { .ok_or_else(|| anyhow!("Failed to retrieve id from GitHub API json response"))?; sqlx::query("insert into sso (user_id, provider, provider_id) values ($1, $2, $3)") - .bind(&user.id) + .bind(user.id) .bind(&SSOProviderType::GitHub) .bind(github_id.as_str()) .execute(&mut transaction) @@ -196,10 +196,10 @@ impl SSOProvider for GitHubSSO { // All email addresses have already been verified by GitHub, so we also mark them as verified sqlx::query("insert into emails (owner, email, \"primary\", commit, notification, public, verified_at) values ($1, $2, $3, $3, $3, $4, current_timestamp)") - .bind(&user.id) + .bind(user.id) .bind(email) - .bind(&primary) - .bind(&public) + .bind(primary) + .bind(public) .execute(&mut transaction) .await?; } diff --git a/src/sso/gitlab_sso.rs b/src/sso/gitlab_sso.rs index e5b5ffc..57f5cdc 100644 --- a/src/sso/gitlab_sso.rs +++ b/src/sso/gitlab_sso.rs @@ -136,7 +136,7 @@ impl SSOProvider for GitLabSSO { .ok_or_else(|| anyhow!("Failed to retrieve id from GitLab API json response"))?; sqlx::query("insert into sso (user_id, provider, provider_id) values ($1, $2, $3)") - .bind(&user.id) + .bind(user.id) .bind(&SSOProviderType::GitLab) .bind(gitlab_id.as_str()) .execute(&mut transaction) @@ -176,9 +176,9 @@ impl SSOProvider for GitLabSSO { }); sqlx::query("insert into emails (owner, email, \"primary\", commit, notification, public) values ($1, $2, $3, $3, $3, $3)") - .bind(&user.id) + .bind(user.id) .bind(email) - .bind(&primary) + .bind(primary) .execute(&mut transaction) .await?; diff --git a/src/templates/filters.rs b/src/templates/filters.rs index 170b287..5cb8e07 100644 --- a/src/templates/filters.rs +++ b/src/templates/filters.rs @@ -21,7 +21,7 @@ pub(crate) fn human_time(value: &Value, _: &HashMap) -> Result = DateTime::from_utc(naive, Utc); + let date_time: DateTime = DateTime::from_naive_utc_and_offset(naive, Utc); let human_time = HumanTime::from(date_time); diff --git a/src/templates/mod.rs b/src/templates/mod.rs index a28cb35..c71aa70 100644 --- a/src/templates/mod.rs +++ b/src/templates/mod.rs @@ -50,7 +50,7 @@ pub(crate) async fn init() -> Result { use actix_web::rt::Runtime; use log::error; - use notify::{Error as NotifyError, Event, RecommendedWatcher, RecursiveMode, Watcher}; + use notify::{Error as NotifyError, Event, RecursiveMode, Watcher}; let mut watcher = notify::recommended_watcher(|result: std::result::Result| { diff --git a/src/user.rs b/src/user.rs index 1ba86a2..34c1ead 100644 --- a/src/user.rs +++ b/src/user.rs @@ -169,7 +169,7 @@ async fn extract_from_request>>( let user: Option = sqlx::query_as::<_, User>("select * from users where id = $1 limit 1") - .bind(&session.user_id) + .bind(session.user_id) .fetch_optional(&mut transaction) .await?; diff --git a/src/verification.rs b/src/verification.rs index 60b3d29..58f787f 100644 --- a/src/verification.rs +++ b/src/verification.rs @@ -14,7 +14,7 @@ pub(crate) async fn send_verification_mail(user: &User, db_pool: &Pool let mut transaction = db_pool.begin().await?; sqlx::query("insert into user_verifications (user_id, hash, expires) values ($1, $2, now() + interval '1 day')") - .bind(&user.id) + .bind(user.id) .bind(&hash) .execute(&mut transaction) .await?;