You've already forked AstralRinth
forked from didirus/AstralRinth
chore(clippy): enable and fix many stricter lints (#3783)
* chore(clippy): enable and fix many stricter lints These ensure that the codebase uses more idiomatic, performant, and concise language constructions. * chore: make non-Clippy compiler warnings also deny by default
This commit is contained in:
committed by
GitHub
parent
301967d204
commit
f84f8c1c2b
@@ -100,10 +100,7 @@ pub async fn filter_visible_project_ids(
|
||||
project.status.is_searchable()
|
||||
} else {
|
||||
!project.status.is_hidden()
|
||||
}) || user_option
|
||||
.as_ref()
|
||||
.map(|x| x.role.is_mod())
|
||||
.unwrap_or(false)
|
||||
}) || user_option.as_ref().is_some_and(|x| x.role.is_mod())
|
||||
{
|
||||
return_projects.push(project.id);
|
||||
} else if user_option.is_some() {
|
||||
@@ -158,7 +155,7 @@ pub async fn filter_enlisted_projects_ids(
|
||||
)
|
||||
.fetch(pool)
|
||||
.map_ok(|row| {
|
||||
for x in projects.iter() {
|
||||
for x in &projects {
|
||||
let bool =
|
||||
Some(x.id.0) == row.id && Some(x.team_id.0) == row.team_id;
|
||||
if bool {
|
||||
@@ -238,7 +235,6 @@ pub async fn filter_visible_version_ids(
|
||||
redis: &RedisPool,
|
||||
) -> Result<Vec<crate::database::models::DBVersionId>, ApiError> {
|
||||
let mut return_versions = Vec::new();
|
||||
let mut check_versions = Vec::new();
|
||||
|
||||
// First, filter out versions belonging to projects we can't see
|
||||
// (ie: a hidden project, but public version, should still be hidden)
|
||||
@@ -271,15 +267,10 @@ pub async fn filter_visible_version_ids(
|
||||
// - we are enlisted on the team of the mod
|
||||
if (!version.status.is_hidden()
|
||||
&& visible_project_ids.contains(&version.project_id))
|
||||
|| user_option
|
||||
.as_ref()
|
||||
.map(|x| x.role.is_mod())
|
||||
.unwrap_or(false)
|
||||
|| user_option.as_ref().is_some_and(|x| x.role.is_mod())
|
||||
|| enlisted_version_ids.contains(&version.id)
|
||||
{
|
||||
return_versions.push(version.id);
|
||||
} else if user_option.is_some() {
|
||||
check_versions.push(version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,10 +301,7 @@ pub async fn filter_enlisted_version_ids(
|
||||
.await?;
|
||||
|
||||
for version in versions {
|
||||
if user_option
|
||||
.as_ref()
|
||||
.map(|x| x.role.is_mod())
|
||||
.unwrap_or(false)
|
||||
if user_option.as_ref().is_some_and(|x| x.role.is_mod())
|
||||
|| (user_option.is_some()
|
||||
&& authorized_project_ids.contains(&version.project_id))
|
||||
{
|
||||
@@ -349,10 +337,7 @@ pub async fn filter_visible_collections(
|
||||
|
||||
for collection in collections {
|
||||
if !collection.status.is_hidden()
|
||||
|| user_option
|
||||
.as_ref()
|
||||
.map(|x| x.role.is_mod())
|
||||
.unwrap_or(false)
|
||||
|| user_option.as_ref().is_some_and(|x| x.role.is_mod())
|
||||
{
|
||||
return_collections.push(collection.into());
|
||||
} else if user_option.is_some() {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::fmt::Write;
|
||||
|
||||
use crate::auth::get_user_from_headers;
|
||||
use crate::auth::oauth::uris::{OAuthRedirectUris, ValidatedRedirectUri};
|
||||
use crate::auth::validate::extract_authorization_header;
|
||||
@@ -17,7 +19,7 @@ use crate::queue::session::AuthQueue;
|
||||
use actix_web::http::header::{CACHE_CONTROL, LOCATION, PRAGMA};
|
||||
use actix_web::web::{Data, Query, ServiceConfig};
|
||||
use actix_web::{HttpRequest, HttpResponse, get, post, web};
|
||||
use chrono::Duration;
|
||||
use chrono::{DateTime, Duration};
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand_chacha::ChaCha20Rng;
|
||||
@@ -280,8 +282,8 @@ pub async fn request_token(
|
||||
authorization_id,
|
||||
token_hash,
|
||||
scopes,
|
||||
created: Default::default(),
|
||||
expires: Default::default(),
|
||||
created: DateTime::default(),
|
||||
expires: DateTime::default(),
|
||||
last_used: None,
|
||||
client_id,
|
||||
user_id,
|
||||
@@ -456,7 +458,7 @@ fn append_params_to_uri(uri: &str, params: &[impl AsRef<str>]) -> String {
|
||||
let mut uri = uri.to_string();
|
||||
let mut connector = if uri.contains('?') { "&" } else { "?" };
|
||||
for param in params {
|
||||
uri.push_str(&format!("{}{}", connector, param.as_ref()));
|
||||
write!(&mut uri, "{connector}{}", param.as_ref()).unwrap();
|
||||
connector = "&";
|
||||
}
|
||||
|
||||
|
||||
@@ -93,12 +93,11 @@ where
|
||||
.await?;
|
||||
|
||||
let rate_limit_ignore = dotenvy::var("RATE_LIMIT_IGNORE_KEY")?;
|
||||
if !req
|
||||
if req
|
||||
.headers()
|
||||
.get("x-ratelimit-key")
|
||||
.and_then(|x| x.to_str().ok())
|
||||
.map(|x| x == rate_limit_ignore)
|
||||
.unwrap_or(false)
|
||||
.is_none_or(|x| x != rate_limit_ignore)
|
||||
{
|
||||
let metadata = get_session_metadata(req).await?;
|
||||
session_queue.add_session(session.id, metadata).await;
|
||||
@@ -130,7 +129,7 @@ where
|
||||
|
||||
user.map(|u| (access_token.scopes, u))
|
||||
}
|
||||
Some(("github", _)) | Some(("gho", _)) | Some(("ghp", _)) => {
|
||||
Some(("github" | "gho" | "ghp", _)) => {
|
||||
let user = AuthProvider::GitHub.get_user(token).await?;
|
||||
let id =
|
||||
AuthProvider::GitHub.get_user_id(&user.id, executor).await?;
|
||||
|
||||
Reference in New Issue
Block a user