mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
chore: Clippy fixes
This commit is contained in:
@@ -4,7 +4,6 @@ mod token;
|
|||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Json, Router,
|
Json, Router,
|
||||||
extract::State,
|
|
||||||
routing::method_routing::{get, post},
|
routing::method_routing::{get, post},
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
use std::{
|
use std::{collections::BTreeSet, fmt::Debug, hash::Hash, mem::discriminant};
|
||||||
collections::{BTreeSet, HashSet},
|
|
||||||
fmt::Debug,
|
|
||||||
hash::Hash,
|
|
||||||
mem::discriminant,
|
|
||||||
};
|
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use ruma::OwnedDeviceId;
|
use ruma::OwnedDeviceId;
|
||||||
@@ -127,6 +122,7 @@ pub enum TokenRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TokenRequest {
|
impl TokenRequest {
|
||||||
|
#[must_use]
|
||||||
pub fn client_id(&self) -> &str {
|
pub fn client_id(&self) -> &str {
|
||||||
match self {
|
match self {
|
||||||
| Self::AuthorizationCode { client_id, .. }
|
| Self::AuthorizationCode { client_id, .. }
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, BTreeSet, HashMap},
|
collections::{BTreeSet, HashMap},
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
@@ -77,10 +77,10 @@ impl PendingCodeGrant {
|
|||||||
const RANDOM_CODE_LENGTH: usize = 32;
|
const RANDOM_CODE_LENGTH: usize = 32;
|
||||||
|
|
||||||
#[must_use]
|
#[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]
|
#[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();
|
let now = SystemTime::now();
|
||||||
|
|
||||||
self.expected_client_id == client_id
|
self.expected_client_id == client_id
|
||||||
@@ -454,7 +454,7 @@ impl Service {
|
|||||||
.remove(&session_info.current_refresh_token);
|
.remove(&session_info.current_refresh_token);
|
||||||
self.db
|
self.db
|
||||||
.userdeviceid_oauthsessioninfo
|
.userdeviceid_oauthsessioninfo
|
||||||
.del(&(user_id, device_id));
|
.del((user_id, device_id));
|
||||||
info!(?user_id, ?device_id, "Removed OAuth session");
|
info!(?user_id, ?device_id, "Removed OAuth session");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use askama::{Template, filters::HtmlSafe};
|
|||||||
use base64::Engine;
|
use base64::Engine;
|
||||||
use conduwuit_core::{result::FlatOk, utils};
|
use conduwuit_core::{result::FlatOk, utils};
|
||||||
use conduwuit_service::{Services, media::mxc::Mxc, oauth::client_metadata::ClientMetadata};
|
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;
|
pub(super) mod form;
|
||||||
|
|
||||||
@@ -24,10 +24,10 @@ impl HtmlSafe for Avatar {}
|
|||||||
|
|
||||||
impl Avatar {
|
impl Avatar {
|
||||||
pub(super) async fn for_local_user(services: &Services, user_id: &UserId) -> Self {
|
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_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 (server_name, media_id) = avatar_url.parts().ok()?;
|
||||||
let file = services
|
let file = services
|
||||||
.media
|
.media
|
||||||
@@ -57,7 +57,7 @@ impl Avatar {
|
|||||||
AvatarType::Initial(user_id.localpart().chars().next().unwrap())
|
AvatarType::Initial(user_id.localpart().chars().next().unwrap())
|
||||||
};
|
};
|
||||||
|
|
||||||
Avatar { avatar_type }
|
Self { avatar_type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ macro_rules! template {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl$(<$lifetime>)? $name$(<$lifetime>)? {
|
impl$(<$lifetime>)? $name$(<$lifetime>)? {
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn new(state: &$crate::State, $($field_name: $field_type,)*) -> Self {
|
fn new(state: &$crate::State, $($field_name: $field_type,)*) -> Self {
|
||||||
Self {
|
Self {
|
||||||
context: state.into(),
|
context: state.into(),
|
||||||
|
|||||||
@@ -3,18 +3,11 @@ use std::collections::BTreeSet;
|
|||||||
use axum::{
|
use axum::{
|
||||||
Router,
|
Router,
|
||||||
extract::{Query, State},
|
extract::{Query, State},
|
||||||
response::{IntoResponse, Redirect},
|
response::Redirect,
|
||||||
routing::on,
|
routing::on,
|
||||||
};
|
};
|
||||||
use conduwuit_service::{
|
use conduwuit_service::oauth::grant::{AuthorizationCodeQuery, Scope};
|
||||||
oauth::{
|
use ruma::OwnedUserId;
|
||||||
client_metadata::{self, ClientMetadata},
|
|
||||||
grant::{AuthorizationCodeQuery, Scope},
|
|
||||||
},
|
|
||||||
rooms::user,
|
|
||||||
};
|
|
||||||
use ruma::{OwnedDeviceId, OwnedUserId};
|
|
||||||
use serde::Deserialize;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::HashMap,
|
|
||||||
mem::discriminant,
|
mem::discriminant,
|
||||||
time::{Duration, SystemTime},
|
time::{Duration, SystemTime},
|
||||||
};
|
};
|
||||||
@@ -8,7 +7,7 @@ use std::{
|
|||||||
use axum::{extract::FromRequestParts, http::request::Parts};
|
use axum::{extract::FromRequestParts, http::request::Parts};
|
||||||
use conduwuit_service::oauth::grant::AuthorizationCodeQuery;
|
use conduwuit_service::oauth::grant::AuthorizationCodeQuery;
|
||||||
use ruma::{OwnedUserId, UserId};
|
use ruma::{OwnedUserId, UserId};
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tower_sessions::Session;
|
use tower_sessions::Session;
|
||||||
|
|
||||||
use crate::{ROUTE_PREFIX, WebError};
|
use crate::{ROUTE_PREFIX, WebError};
|
||||||
|
|||||||
Reference in New Issue
Block a user