style: cargo clippy --fix && cargo fmt
This commit is contained in:
parent
ad24215fef
commit
8e31dc7aca
2 changed files with 14 additions and 12 deletions
|
@ -2,46 +2,49 @@ use std::sync::Arc;
|
|||
|
||||
use axum::{
|
||||
Extension,
|
||||
extract::{Path, State, Json},
|
||||
extract::{Json, Path, State},
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
};
|
||||
use diesel::{insert_into, RunQueryDsl};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
api::v1::auth::CurrentUser, error::Error, objects::{Me, Member, Permissions}, schema::guild_bans::{self, dsl}, utils::global_checks, AppState
|
||||
AppState,
|
||||
api::v1::auth::CurrentUser,
|
||||
error::Error,
|
||||
objects::{Member, Permissions},
|
||||
utils::global_checks,
|
||||
};
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RequstBody {
|
||||
reason: String
|
||||
reason: String,
|
||||
}
|
||||
|
||||
|
||||
pub async fn post(
|
||||
State(app_state): State<Arc<AppState>>,
|
||||
Path(member_uuid): Path<Uuid>,
|
||||
Extension(CurrentUser(uuid)): Extension<CurrentUser<Uuid>>,
|
||||
Json(payload): Json<RequstBody>,
|
||||
) -> Result<impl IntoResponse, Error>{
|
||||
) -> Result<impl IntoResponse, Error> {
|
||||
global_checks(&app_state, uuid).await?;
|
||||
|
||||
let mut conn = app_state.pool.get().await?;
|
||||
|
||||
|
||||
let member = Member::fetch_one_with_member(&app_state, None, member_uuid).await?;
|
||||
|
||||
if member.is_owner {
|
||||
return Err(Error::Forbidden("Not allowed".to_string()));
|
||||
}
|
||||
|
||||
|
||||
let baner = Member::check_membership(&mut conn, uuid, member.guild_uuid).await?;
|
||||
baner.check_permission(&app_state, Permissions::ManageMember).await?;
|
||||
baner
|
||||
.check_permission(&app_state, Permissions::ManageMember)
|
||||
.await?;
|
||||
|
||||
member.ban(&mut conn, &payload.reason).await?;
|
||||
|
||||
|
||||
Ok(StatusCode::OK)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use axum::http::StatusCode;
|
||||
use diesel::{
|
||||
ExpressionMethods, Insertable, QueryDsl, Queryable, Selectable, SelectableHelper, delete,
|
||||
insert_into,
|
||||
|
@ -11,8 +10,8 @@ use crate::{
|
|||
AppState, Conn,
|
||||
error::Error,
|
||||
objects::{Me, Permissions, Role},
|
||||
schema::guild_members,
|
||||
schema::guild_bans,
|
||||
schema::guild_members,
|
||||
};
|
||||
|
||||
use super::{User, load_or_empty};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue