style: cargo clippy && format
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful

This commit is contained in:
Radical 2025-05-24 01:09:17 +02:00
parent 860fa7a66e
commit 8605b81e7b
26 changed files with 274 additions and 178 deletions

View file

@ -1,7 +1,7 @@
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Channel, Member},
utils::get_auth_header,
};
@ -43,8 +43,7 @@ pub async fn get(
let channels = Channel::fetch_all(&data.pool, guild_uuid).await?;
data
.set_cache_key(format!("{}_channels", guild_uuid), channels.clone(), 1800)
data.set_cache_key(format!("{}_channels", guild_uuid), channels.clone(), 1800)
.await?;
Ok(HttpResponse::Ok().json(channels))

View file

@ -1,7 +1,7 @@
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Channel, Member},
utils::get_auth_header,
};
@ -41,8 +41,7 @@ pub async fn get(
} else {
channel = Channel::fetch_one(&mut conn, channel_uuid).await?;
data
.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
data.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
.await?;
}

View file

@ -2,14 +2,14 @@ pub mod messages;
pub mod socket;
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Channel, Member},
utils::get_auth_header,
};
use uuid::Uuid;
use actix_web::{HttpRequest, HttpResponse, delete, get, web};
use uuid::Uuid;
#[get("{uuid}/channels/{channel_uuid}")]
pub async fn get(
@ -37,8 +37,7 @@ pub async fn get(
let channel = Channel::fetch_one(&mut conn, channel_uuid).await?;
data
.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
data.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
.await?;
Ok(HttpResponse::Ok().json(channel))

View file

@ -26,7 +26,7 @@ pub async fn echo(
// Get uuids from path
let (guild_uuid, channel_uuid) = path.into_inner();
let mut conn = data.pool.get().await.map_err(|e| crate::error::Error::from(e))?;
let mut conn = data.pool.get().await.map_err(crate::error::Error::from)?;
// Authorize client using auth header
let uuid = check_access_token(auth_header, &mut conn).await?;
@ -42,8 +42,7 @@ pub async fn echo(
} else {
channel = Channel::fetch_one(&mut conn, channel_uuid).await?;
data
.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
data.set_cache_key(format!("{}", channel_uuid), channel.clone(), 60)
.await?;
}
@ -54,7 +53,11 @@ pub async fn echo(
// aggregate continuation frames up to 1MiB
.max_continuation_size(2_usize.pow(20));
let mut pubsub = data.cache_pool.get_async_pubsub().await.map_err(|e| crate::error::Error::from(e))?;
let mut pubsub = data
.cache_pool
.get_async_pubsub()
.await
.map_err(crate::error::Error::from)?;
let mut session_2 = session_1.clone();

View file

@ -1,8 +1,14 @@
use actix_web::{put, web, HttpRequest, HttpResponse};
use uuid::Uuid;
use actix_web::{HttpRequest, HttpResponse, put, web};
use futures_util::StreamExt as _;
use uuid::Uuid;
use crate::{error::Error, api::v1::auth::check_access_token, structs::{Guild, Member}, utils::get_auth_header, Data};
use crate::{
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Guild, Member},
utils::get_auth_header,
};
#[put("{uuid}/icon")]
pub async fn upload(
@ -30,7 +36,14 @@ pub async fn upload(
bytes.extend_from_slice(&item?);
}
guild.set_icon(&data.bunny_cdn, &mut conn, data.config.bunny.cdn_url.clone(), bytes).await?;
guild
.set_icon(
&data.bunny_cdn,
&mut conn,
data.config.bunny.cdn_url.clone(),
bytes,
)
.await?;
Ok(HttpResponse::Ok().finish())
}

View file

@ -3,9 +3,9 @@ use serde::Deserialize;
use uuid::Uuid;
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Guild, Member},
utils::get_auth_header,
};

View file

@ -2,14 +2,14 @@ use actix_web::{HttpRequest, HttpResponse, Scope, get, web};
use uuid::Uuid;
mod channels;
mod icon;
mod invites;
mod roles;
mod icon;
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Guild, Member},
utils::get_auth_header,
};

View file

@ -3,9 +3,9 @@ use actix_web::{HttpRequest, HttpResponse, get, post, web};
use serde::Deserialize;
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Member, Role},
utils::get_auth_header,
};
@ -43,8 +43,7 @@ pub async fn get(
let roles = Role::fetch_all(&mut conn, guild_uuid).await?;
data
.set_cache_key(format!("{}_roles", guild_uuid), roles.clone(), 1800)
data.set_cache_key(format!("{}_roles", guild_uuid), roles.clone(), 1800)
.await?;
Ok(HttpResponse::Ok().json(roles))

View file

@ -1,7 +1,7 @@
use crate::{
error::Error,
Data,
api::v1::auth::check_access_token,
error::Error,
structs::{Member, Role},
utils::get_auth_header,
};
@ -34,8 +34,7 @@ pub async fn get(
let role = Role::fetch_one(&mut conn, role_uuid).await?;
data
.set_cache_key(format!("{}", role_uuid), role.clone(), 60)
data.set_cache_key(format!("{}", role_uuid), role.clone(), 60)
.await?;
Ok(HttpResponse::Ok().json(role))