From 3dc4c7d4fc7f2083a49b14184946b7a8a49a961d Mon Sep 17 00:00:00 2001 From: Ginger Date: Thu, 30 Apr 2026 09:05:34 -0400 Subject: [PATCH] chore: Clippy fixes --- src/api/client/oauth/mod.rs | 1 - src/service/oauth/grant.rs | 8 ++------ src/service/oauth/mod.rs | 8 ++++---- src/web/pages/components/mod.rs | 8 ++++---- src/web/pages/mod.rs | 1 + src/web/pages/oauth/grant.rs | 13 +++---------- src/web/session/mod.rs | 3 +-- 7 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/api/client/oauth/mod.rs b/src/api/client/oauth/mod.rs index 4ba91cd75..2fb373984 100644 --- a/src/api/client/oauth/mod.rs +++ b/src/api/client/oauth/mod.rs @@ -4,7 +4,6 @@ mod token; use axum::{ Json, Router, - extract::State, routing::method_routing::{get, post}, }; use serde_json::json; diff --git a/src/service/oauth/grant.rs b/src/service/oauth/grant.rs index 261910501..b60c0fd41 100644 --- a/src/service/oauth/grant.rs +++ b/src/service/oauth/grant.rs @@ -1,9 +1,4 @@ -use std::{ - collections::{BTreeSet, HashSet}, - fmt::Debug, - hash::Hash, - mem::discriminant, -}; +use std::{collections::BTreeSet, fmt::Debug, hash::Hash, mem::discriminant}; use regex::Regex; use ruma::OwnedDeviceId; @@ -127,6 +122,7 @@ pub enum TokenRequest { } impl TokenRequest { + #[must_use] pub fn client_id(&self) -> &str { match self { | Self::AuthorizationCode { client_id, .. } diff --git a/src/service/oauth/mod.rs b/src/service/oauth/mod.rs index 33c9dd40c..45dba301a 100644 --- a/src/service/oauth/mod.rs +++ b/src/service/oauth/mod.rs @@ -1,5 +1,5 @@ use std::{ - collections::{BTreeMap, BTreeSet, HashMap}, + collections::{BTreeSet, HashMap}, sync::{Arc, Mutex}, time::{Duration, SystemTime}, }; @@ -77,10 +77,10 @@ impl PendingCodeGrant { const RANDOM_CODE_LENGTH: usize = 32; #[must_use] - pub fn generate_code() -> String { utils::random_string(Self::RANDOM_CODE_LENGTH) } + pub(crate) fn generate_code() -> String { utils::random_string(Self::RANDOM_CODE_LENGTH) } #[must_use] - pub fn is_valid_for(&self, client_id: &str) -> bool { + pub(crate) fn is_valid_for(&self, client_id: &str) -> bool { let now = SystemTime::now(); self.expected_client_id == client_id @@ -454,7 +454,7 @@ impl Service { .remove(&session_info.current_refresh_token); self.db .userdeviceid_oauthsessioninfo - .del(&(user_id, device_id)); + .del((user_id, device_id)); info!(?user_id, ?device_id, "Removed OAuth session"); } } diff --git a/src/web/pages/components/mod.rs b/src/web/pages/components/mod.rs index ff336aa0c..25377100c 100644 --- a/src/web/pages/components/mod.rs +++ b/src/web/pages/components/mod.rs @@ -4,7 +4,7 @@ use askama::{Template, filters::HtmlSafe}; use base64::Engine; use conduwuit_core::{result::FlatOk, utils}; use conduwuit_service::{Services, media::mxc::Mxc, oauth::client_metadata::ClientMetadata}; -use ruma::{MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedUserId, UserId}; +use ruma::{OwnedDeviceId, OwnedUserId, UserId}; pub(super) mod form; @@ -24,10 +24,10 @@ impl HtmlSafe for Avatar {} impl Avatar { pub(super) async fn for_local_user(services: &Services, user_id: &UserId) -> Self { - let display_name = services.users.displayname(&user_id).await.ok(); + let display_name = services.users.displayname(user_id).await.ok(); let avatar_src = async { - let avatar_url = services.users.avatar_url(&user_id).await.ok()?; + let avatar_url = services.users.avatar_url(user_id).await.ok()?; let (server_name, media_id) = avatar_url.parts().ok()?; let file = services .media @@ -57,7 +57,7 @@ impl Avatar { AvatarType::Initial(user_id.localpart().chars().next().unwrap()) }; - Avatar { avatar_type } + Self { avatar_type } } } diff --git a/src/web/pages/mod.rs b/src/web/pages/mod.rs index 39bed84be..ba6edf3d8 100644 --- a/src/web/pages/mod.rs +++ b/src/web/pages/mod.rs @@ -42,6 +42,7 @@ macro_rules! template { } impl$(<$lifetime>)? $name$(<$lifetime>)? { + #[allow(clippy::too_many_arguments)] fn new(state: &$crate::State, $($field_name: $field_type,)*) -> Self { Self { context: state.into(), diff --git a/src/web/pages/oauth/grant.rs b/src/web/pages/oauth/grant.rs index c45ea5435..500f09521 100644 --- a/src/web/pages/oauth/grant.rs +++ b/src/web/pages/oauth/grant.rs @@ -3,18 +3,11 @@ use std::collections::BTreeSet; use axum::{ Router, extract::{Query, State}, - response::{IntoResponse, Redirect}, + response::Redirect, routing::on, }; -use conduwuit_service::{ - oauth::{ - client_metadata::{self, ClientMetadata}, - grant::{AuthorizationCodeQuery, Scope}, - }, - rooms::user, -}; -use ruma::{OwnedDeviceId, OwnedUserId}; -use serde::Deserialize; +use conduwuit_service::oauth::grant::{AuthorizationCodeQuery, Scope}; +use ruma::OwnedUserId; use url::Url; use crate::{ diff --git a/src/web/session/mod.rs b/src/web/session/mod.rs index 21833fc06..6694b826f 100644 --- a/src/web/session/mod.rs +++ b/src/web/session/mod.rs @@ -1,6 +1,5 @@ use std::{ borrow::Cow, - collections::HashMap, mem::discriminant, time::{Duration, SystemTime}, }; @@ -8,7 +7,7 @@ use std::{ use axum::{extract::FromRequestParts, http::request::Parts}; use conduwuit_service::oauth::grant::AuthorizationCodeQuery; use ruma::{OwnedUserId, UserId}; -use serde::{Deserialize, Deserializer, Serialize}; +use serde::{Deserialize, Serialize}; use tower_sessions::Session; use crate::{ROUTE_PREFIX, WebError};